]> git.sur5r.net Git - openldap/blob - build/ltmain.sh
Distribute missing for folks who don't have autoconf/automake/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 ltconfig.
3 #
4 # Copyright (C) 1996-1999 Free Software Foundation, Inc.
5 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #
21 # As a special exception to the GNU General Public License, if you
22 # distribute this file as part of a program that contains a
23 # configuration script generated by Autoconf, you may include it under
24 # the same distribution terms that you use for the rest of that program.
25
26 # Check that we have a working $echo.
27 if test "X$1" = X--no-reexec; then
28   # Discard the --no-reexec flag, and continue.
29   shift
30 elif test "X$1" = X--fallback-echo; then
31   # Avoid inline document here, it may be left over
32   :
33 elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
34   # Yippee, $echo works!
35   :
36 else
37   # Restart under the correct shell, and then maybe $echo will work.
38   exec $SHELL "$0" --no-reexec ${1+"$@"}
39 fi
40
41 if test "X$1" = X--fallback-echo; then
42   # used as fallback echo
43   shift
44   cat <<EOF
45 $*
46 EOF
47   exit 0
48 fi
49
50 # The name of this program.
51 progname=`$echo "$0" | sed 's%^.*/%%'`
52 modename="$progname"
53
54 # Constants.
55 PROGRAM=ltmain.sh
56 PACKAGE=libtool
57 VERSION=1.3.3
58 TIMESTAMP=" (1.385.2.181 1999/07/02 15:49:11)"
59
60 default_mode=
61 help="Try \`$progname --help' for more information."
62 magic="%%%MAGIC variable%%%"
63 mkdir="mkdir"
64 mv="mv -f"
65 rm="rm -f"
66
67 # Sed substitution that helps us do robust quoting.  It backslashifies
68 # metacharacters that are still active within double-quoted strings.
69 Xsed='sed -e 1s/^X//'
70 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
71 SP2NL='tr \040 \012'
72 NL2SP='tr \015\012 \040\040'
73
74 # NLS nuisances.
75 # Only set LANG and LC_ALL to C if already set.
76 # These must not be set unconditionally because not all systems understand
77 # e.g. LANG=C (notably SCO).
78 # We save the old values to restore during execute mode.
79 if test "${LC_ALL+set}" = set; then
80   save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
81 fi
82 if test "${LANG+set}" = set; then
83   save_LANG="$LANG"; LANG=C; export LANG
84 fi
85
86 if test "$LTCONFIG_VERSION" != "$VERSION"; then
87   echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2
88   echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
89   exit 1
90 fi
91
92 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
93   echo "$modename: not configured to build any kind of library" 1>&2
94   echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
95   exit 1
96 fi
97
98 # Global variables.
99 mode=$default_mode
100 nonopt=
101 prev=
102 prevopt=
103 run=
104 show="$echo"
105 show_help=
106 execute_dlfiles=
107 lo2o="s/\\.lo\$/.${objext}/"
108 o2lo="s/\\.${objext}\$/.lo/"
109
110 # Parse our command line options once, thoroughly.
111 while test $# -gt 0
112 do
113   arg="$1"
114   shift
115
116   case "$arg" in
117   -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
118   *) optarg= ;;
119   esac
120
121   # If the previous option needs an argument, assign it.
122   if test -n "$prev"; then
123     case "$prev" in
124     execute_dlfiles)
125       eval "$prev=\"\$$prev \$arg\""
126       ;;
127     *)
128       eval "$prev=\$arg"
129       ;;
130     esac
131
132     prev=
133     prevopt=
134     continue
135   fi
136
137   # Have we seen a non-optional argument yet?
138   case "$arg" in
139   --help)
140     show_help=yes
141     ;;
142
143   --version)
144     echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
145     exit 0
146     ;;
147
148   --config)
149     sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0
150     exit 0
151     ;;
152
153   --debug)
154     echo "$progname: enabling shell trace mode"
155     set -x
156     ;;
157
158   --dry-run | -n)
159     run=:
160     ;;
161
162   --features)
163     echo "host: $host"
164     if test "$build_libtool_libs" = yes; then
165       echo "enable shared libraries"
166     else
167       echo "disable shared libraries"
168     fi
169     if test "$build_old_libs" = yes; then
170       echo "enable static libraries"
171     else
172       echo "disable static libraries"
173     fi
174     exit 0
175     ;;
176
177   --finish) mode="finish" ;;
178
179   --mode) prevopt="--mode" prev=mode ;;
180   --mode=*) mode="$optarg" ;;
181
182   --only-shared)
183     build_libtool_libs=yes
184     build_old_libs=no
185     ;;
186
187   --only-static)
188     build_libtool_libs=no
189     build_old_libs=yes
190     ;;
191
192   --quiet | --silent)
193     show=:
194     ;;
195
196   -dlopen)
197     prevopt="-dlopen"
198     prev=execute_dlfiles
199     ;;
200
201   -*)
202     $echo "$modename: unrecognized option \`$arg'" 1>&2
203     $echo "$help" 1>&2
204     exit 1
205     ;;
206
207   *)
208     nonopt="$arg"
209     break
210     ;;
211   esac
212 done
213
214 if test -n "$prevopt"; then
215   $echo "$modename: option \`$prevopt' requires an argument" 1>&2
216   $echo "$help" 1>&2
217   exit 1
218 fi
219
220 case "$show $MFLAGS -$MAKEFLAGS" in
221   :\ *) : ;;
222   *\ -*s*)
223         # Be silent inside 'make -s'
224         expr " $MFLAGS -$MAKEFLAGS" : '.* -[a-zA-Z]*s' >/dev/null && show=: ;;
225 esac
226
227 if test -z "$show_help"; then
228
229   # Infer the operation mode.
230   if test -z "$mode"; then
231     case "$nonopt" in
232     *cc | *++ | gcc* | *-gcc*)
233       mode=link
234       for arg
235       do
236         case "$arg" in
237         -c)
238            mode=compile
239            break
240            ;;
241         esac
242       done
243       ;;
244     *db | *dbx | *strace | *truss)
245       mode=execute
246       ;;
247     *install*|cp|mv)
248       mode=install
249       ;;
250     *rm)
251       mode=uninstall
252       ;;
253     *)
254       # If we have no mode, but dlfiles were specified, then do execute mode.
255       test -n "$execute_dlfiles" && mode=execute
256
257       # Just use the default operation mode.
258       if test -z "$mode"; then
259         if test -n "$nonopt"; then
260           $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
261         else
262           $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
263         fi
264       fi
265       ;;
266     esac
267   fi
268
269   # Only execute mode is allowed to have -dlopen flags.
270   if test -n "$execute_dlfiles" && test "$mode" != execute; then
271     $echo "$modename: unrecognized option \`-dlopen'" 1>&2
272     $echo "$help" 1>&2
273     exit 1
274   fi
275
276   # Change the help message to a mode-specific one.
277   generic_help="$help"
278   help="Try \`$modename --help --mode=$mode' for more information."
279
280   # These modes are in order of execution frequency so that they run quickly.
281   case "$mode" in
282   # libtool compile mode
283   compile)
284     modename="$modename: compile"
285     # Get the compilation command and the source file.
286     base_compile=
287     lastarg=
288     srcfile="$nonopt"
289     suppress_output=
290
291     user_target=no
292     for arg
293     do
294       # Accept any command-line options.
295       case "$arg" in
296       -o)
297         if test "$user_target" != "no"; then
298           $echo "$modename: you cannot specify \`-o' more than once" 1>&2
299           exit 1
300         fi
301         user_target=next
302         ;;
303
304       -static)
305         build_old_libs=yes
306         continue
307         ;;
308       esac
309
310       case "$user_target" in
311       next)
312         # The next one is the -o target name
313         user_target=yes
314         continue
315         ;;
316       yes)
317         # We got the output file
318         user_target=set
319         libobj="$arg"
320         continue
321         ;;
322       esac
323
324       # Accept the current argument as the source file.
325       lastarg="$srcfile"
326       srcfile="$arg"
327
328       # Aesthetically quote the previous argument.
329
330       # Backslashify any backslashes, double quotes, and dollar signs.
331       # These are the only characters that are still specially
332       # interpreted inside of double-quoted scrings.
333       lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
334
335       # Double-quote args containing other shell metacharacters.
336       # Many Bourne shells cannot handle close brackets correctly in scan
337       # sets, so we specify it separately.
338       case "$lastarg" in
339       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*)
340         lastarg="\"$lastarg\""
341         ;;
342       esac
343
344       # Add the previous argument to base_compile.
345       if test -z "$base_compile"; then
346         base_compile="$lastarg"
347       else
348         base_compile="$base_compile $lastarg"
349       fi
350     done
351
352     case "$user_target" in
353     set)
354       ;;
355     no)
356       # Get the name of the library object.
357       libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
358       ;;
359     *)
360       $echo "$modename: you must specify a target with \`-o'" 1>&2
361       exit 1
362       ;;
363     esac
364
365     # Recognize several different file suffixes.
366     # If the user specifies -o file.o, it is replaced with file.lo
367     xform='[cCFSfmso]'
368     case "$libobj" in
369     *.ada) xform=ada ;;
370     *.adb) xform=adb ;;
371     *.ads) xform=ads ;;
372     *.asm) xform=asm ;;
373     *.c++) xform=c++ ;;
374     *.cc) xform=cc ;;
375     *.cpp) xform=cpp ;;
376     *.cxx) xform=cxx ;;
377     *.f90) xform=f90 ;;
378     *.for) xform=for ;;
379     esac
380
381     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
382
383     case "$libobj" in
384     *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
385     *)
386       $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
387       exit 1
388       ;;
389     esac
390
391     if test -z "$base_compile"; then
392       $echo "$modename: you must specify a compilation command" 1>&2
393       $echo "$help" 1>&2
394       exit 1
395     fi
396
397     # Delete any leftover library objects.
398     if test "$build_old_libs" = yes; then
399       removelist="$obj $libobj"
400     else
401       removelist="$libobj"
402     fi
403
404     $run $rm $removelist
405     trap "$run $rm $removelist; exit 1" 1 2 15
406
407     # Calculate the filename of the output object if compiler does
408     # not support -o with -c
409     if test "$compiler_c_o" = no; then
410       output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext}
411       lockfile="$output_obj.lock"
412       removelist="$removelist $output_obj $lockfile"
413       trap "$run $rm $removelist; exit 1" 1 2 15
414     else
415       need_locks=no
416       lockfile=
417     fi
418
419     # Lock this critical section if it is needed
420     # We use this script file to make the link, it avoids creating a new file
421     if test "$need_locks" = yes; then
422       until ln "$0" "$lockfile" 2>/dev/null; do
423         $show "Waiting for $lockfile to be removed"
424         sleep 2
425       done
426     elif test "$need_locks" = warn; then
427       if test -f "$lockfile"; then
428         echo "\
429 *** ERROR, $lockfile exists and contains:
430 `cat $lockfile 2>/dev/null`
431
432 This indicates that another process is trying to use the same
433 temporary object file, and libtool could not work around it because
434 your compiler does not support \`-c' and \`-o' together.  If you
435 repeat this compilation, it may succeed, by chance, but you had better
436 avoid parallel builds (make -j) in this platform, or get a better
437 compiler."
438
439         $run $rm $removelist
440         exit 1
441       fi
442       echo $srcfile > "$lockfile"
443     fi
444
445     if test -n "$fix_srcfile_path"; then
446       eval srcfile=\"$fix_srcfile_path\"
447     fi
448
449     # Only build a PIC object if we are building libtool libraries.
450     if test "$build_libtool_libs" = yes; then
451       # Without this assignment, base_compile gets emptied.
452       fbsd_hideous_sh_bug=$base_compile
453
454       # All platforms use -DPIC, to notify preprocessed assembler code.
455       command="$base_compile $pic_flag -DPIC $srcfile"
456       if test "$build_old_libs" = yes; then
457         lo_libobj="$libobj"
458         dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
459         if test "X$dir" = "X$libobj"; then
460           dir="$objdir"
461         else
462           dir="$dir/$objdir"
463         fi
464         libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
465
466         if test -d "$dir"; then
467           $show "$rm $libobj"
468           $run $rm $libobj
469         else
470           $show "$mkdir $dir"
471           $run $mkdir $dir
472           status=$?
473           if test $status -ne 0 && test ! -d $dir; then
474             exit $status
475           fi
476         fi
477       fi
478       if test "$compiler_o_lo" = yes; then
479         output_obj="$libobj"
480         command="$command -o $output_obj"
481       elif test "$compiler_c_o" = yes; then
482         output_obj="$obj"
483         command="$command -o $output_obj"
484       fi
485
486       $run $rm "$output_obj"
487       $show "$command"
488       if $run eval "$command"; then :
489       else
490         test -n "$output_obj" && $run $rm $removelist
491         exit 1
492       fi
493
494       if test "$need_locks" = warn &&
495          test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
496         echo "\
497 *** ERROR, $lockfile contains:
498 `cat $lockfile 2>/dev/null`
499
500 but it should contain:
501 $srcfile
502
503 This indicates that another process is trying to use the same
504 temporary object file, and libtool could not work around it because
505 your compiler does not support \`-c' and \`-o' together.  If you
506 repeat this compilation, it may succeed, by chance, but you had better
507 avoid parallel builds (make -j) in this platform, or get a better
508 compiler."
509
510         $run $rm $removelist
511         exit 1
512       fi
513
514       # Just move the object if needed, then go on to compile the next one
515       if test x"$output_obj" != x"$libobj"; then
516         $show "$mv $output_obj $libobj"
517         if $run $mv $output_obj $libobj; then :
518         else
519           error=$?
520           $run $rm $removelist
521           exit $error
522         fi
523       fi
524
525       # If we have no pic_flag, then copy the object into place and finish.
526       if test -z "$pic_flag" && test "$build_old_libs" = yes; then
527         # Rename the .lo from within objdir to obj
528         if test -f $obj; then
529           $show $rm $obj
530           $run $rm $obj
531         fi
532
533         $show "$mv $libobj $obj"
534         if $run $mv $libobj $obj; then :
535         else
536           error=$?
537           $run $rm $removelist
538           exit $error
539         fi
540
541         # Now arrange that obj and lo_libobj become the same file
542         $show "$LN_S $obj $lo_libobj"
543         if $run $LN_S $obj $lo_libobj; then
544           exit 0
545         else
546           error=$?
547           $run $rm $removelist
548           exit $error
549         fi
550       fi
551
552       # Allow error messages only from the first compilation.
553       suppress_output=' >/dev/null 2>&1'
554     fi
555
556     # Only build a position-dependent object if we build old libraries.
557     if test "$build_old_libs" = yes; then
558       command="$base_compile $srcfile"
559       if test "$compiler_c_o" = yes; then
560         command="$command -o $obj"
561         output_obj="$obj"
562       fi
563
564       # Suppress compiler output if we already did a PIC compilation.
565       command="$command$suppress_output"
566       $run $rm "$output_obj"
567       $show "$command"
568       if $run eval "$command"; then :
569       else
570         $run $rm $removelist
571         exit 1
572       fi
573
574       if test "$need_locks" = warn &&
575          test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
576         echo "\
577 *** ERROR, $lockfile contains:
578 `cat $lockfile 2>/dev/null`
579
580 but it should contain:
581 $srcfile
582
583 This indicates that another process is trying to use the same
584 temporary object file, and libtool could not work around it because
585 your compiler does not support \`-c' and \`-o' together.  If you
586 repeat this compilation, it may succeed, by chance, but you had better
587 avoid parallel builds (make -j) in this platform, or get a better
588 compiler."
589
590         $run $rm $removelist
591         exit 1
592       fi
593
594       # Just move the object if needed
595       if test x"$output_obj" != x"$obj"; then
596         $show "$mv $output_obj $obj"
597         if $run $mv $output_obj $obj; then :
598         else
599           error=$?
600           $run $rm $removelist
601           exit $error
602         fi
603       fi
604
605       # Create an invalid libtool object if no PIC, so that we do not
606       # accidentally link it into a program.
607       if test "$build_libtool_libs" != yes; then
608         $show "echo timestamp > $libobj"
609         $run eval "echo timestamp > \$libobj" || exit $?
610       else
611         # Move the .lo from within objdir
612         $show "$mv $libobj $lo_libobj"
613         if $run $mv $libobj $lo_libobj; then :
614         else
615           error=$?
616           $run $rm $removelist
617           exit $error
618         fi
619       fi
620     fi
621
622     # Unlock the critical section if it was locked
623     if test "$need_locks" != no; then
624       $rm "$lockfile"
625     fi
626
627     exit 0
628     ;;
629
630   # libtool link mode
631   link)
632     modename="$modename: link"
633     C_compiler="$CC" # save it, to compile generated C sources
634     CC="$nonopt"
635     case "$host" in
636     *-*-cygwin* | *-*-mingw* | *-*-os2*)
637       # It is impossible to link a dll without this setting, and
638       # we shouldn't force the makefile maintainer to figure out
639       # which system we are compiling for in order to pass an extra
640       # flag for every libtool invokation.
641       # allow_undefined=no
642
643       # FIXME: Unfortunately, there are problems with the above when trying
644       # to make a dll which has undefined symbols, in which case not
645       # even a static library is built.  For now, we need to specify
646       # -no-undefined on the libtool link line when we can be certain
647       # that all symbols are satisfied, otherwise we get a static library.
648       allow_undefined=yes
649
650       # This is a source program that is used to create dlls on Windows
651       # Don't remove nor modify the starting and closing comments
652 # /* ltdll.c starts here */
653 # #define WIN32_LEAN_AND_MEAN
654 # #include <windows.h>
655 # #undef WIN32_LEAN_AND_MEAN
656 # #include <stdio.h>
657 #
658 # #ifndef __CYGWIN__
659 # #  ifdef __CYGWIN32__
660 # #    define __CYGWIN__ __CYGWIN32__
661 # #  endif
662 # #endif
663 #
664 # #ifdef __cplusplus
665 # extern "C" {
666 # #endif
667 # BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
668 # #ifdef __cplusplus
669 # }
670 # #endif
671 #
672 # #ifdef __CYGWIN__
673 # #include <cygwin/cygwin_dll.h>
674 # DECLARE_CYGWIN_DLL( DllMain );
675 # #endif
676 # HINSTANCE __hDllInstance_base;
677 #
678 # BOOL APIENTRY
679 # DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
680 # {
681 #   __hDllInstance_base = hInst;
682 #   return TRUE;
683 # }
684 # /* ltdll.c ends here */
685       # This is a source program that is used to create import libraries
686       # on Windows for dlls which lack them. Don't remove nor modify the
687       # starting and closing comments
688 # /* impgen.c starts here */
689 # /*   Copyright (C) 1999 Free Software Foundation, Inc.
690
691 #  This file is part of GNU libtool.
692
693 #  This program is free software; you can redistribute it and/or modify
694 #  it under the terms of the GNU General Public License as published by
695 #  the Free Software Foundation; either version 2 of the License, or
696 #  (at your option) any later version.
697
698 #  This program is distributed in the hope that it will be useful,
699 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
700 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
701 #  GNU General Public License for more details.
702
703 #  You should have received a copy of the GNU General Public License
704 #  along with this program; if not, write to the Free Software
705 #  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
706 #  */
707
708 #  #include <stdio.h>           /* for printf() */
709 #  #include <unistd.h>          /* for open(), lseek(), read() */
710 #  #include <fcntl.h>           /* for O_RDONLY, O_BINARY */
711 #  #include <string.h>          /* for strdup() */
712
713 #  static unsigned int
714 #  pe_get16 (fd, offset)
715 #       int fd;
716 #       int offset;
717 #  {
718 #    unsigned char b[2];
719 #    lseek (fd, offset, SEEK_SET);
720 #    read (fd, b, 2);
721 #    return b[0] + (b[1]<<8);
722 #  }
723
724 #  static unsigned int
725 #  pe_get32 (fd, offset)
726 #      int fd;
727 #      int offset;
728 #  {
729 #    unsigned char b[4];
730 #    lseek (fd, offset, SEEK_SET);
731 #    read (fd, b, 4);
732 #    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
733 #  }
734
735 #  static unsigned int
736 #  pe_as32 (ptr)
737 #       void *ptr;
738 #  {
739 #    unsigned char *b = ptr;
740 #    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
741 #  }
742
743 #  int
744 #  main (argc, argv)
745 #      int argc;
746 #      char *argv[];
747 #  {
748 #      int dll;
749 #      unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
750 #      unsigned long export_rva, export_size, nsections, secptr, expptr;
751 #      unsigned long name_rvas, nexp;
752 #      unsigned char *expdata, *erva;
753 #      char *filename, *dll_name;
754
755 #      filename = argv[1];
756
757 #      dll = open(filename, O_RDONLY|O_BINARY);
758 #      if (!dll)
759 #       return 1;
760
761 #      dll_name = filename;
762 #    
763 #      for (i=0; filename[i]; i++)
764 #       if (filename[i] == '/' || filename[i] == '\\'  || filename[i] == ':')
765 #           dll_name = filename + i +1;
766
767 #      pe_header_offset = pe_get32 (dll, 0x3c);
768 #      opthdr_ofs = pe_header_offset + 4 + 20;
769 #      num_entries = pe_get32 (dll, opthdr_ofs + 92);
770
771 #      if (num_entries < 1) /* no exports */
772 #       return 1;
773
774 #      export_rva = pe_get32 (dll, opthdr_ofs + 96);
775 #      export_size = pe_get32 (dll, opthdr_ofs + 100);
776 #      nsections = pe_get16 (dll, pe_header_offset + 4 +2);
777 #      secptr = (pe_header_offset + 4 + 20 +
778 #             pe_get16 (dll, pe_header_offset + 4 + 16));
779
780 #      expptr = 0;
781 #      for (i = 0; i < nsections; i++)
782 #      {
783 #       char sname[8];
784 #       unsigned long secptr1 = secptr + 40 * i;
785 #       unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
786 #       unsigned long vsize = pe_get32 (dll, secptr1 + 16);
787 #       unsigned long fptr = pe_get32 (dll, secptr1 + 20);
788 #       lseek(dll, secptr1, SEEK_SET);
789 #       read(dll, sname, 8);
790 #       if (vaddr <= export_rva && vaddr+vsize > export_rva)
791 #       {
792 #           expptr = fptr + (export_rva - vaddr);
793 #           if (export_rva + export_size > vaddr + vsize)
794 #               export_size = vsize - (export_rva - vaddr);
795 #           break;
796 #       }
797 #      }
798
799 #      expdata = (unsigned char*)malloc(export_size);
800 #      lseek (dll, expptr, SEEK_SET);
801 #      read (dll, expdata, export_size);
802 #      erva = expdata - export_rva;
803
804 #      nexp = pe_as32 (expdata+24);
805 #      name_rvas = pe_as32 (expdata+32);
806
807 #      printf ("EXPORTS\n");
808 #      for (i = 0; i<nexp; i++)
809 #      {
810 #       unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
811 #       printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
812 #      }
813
814 #      return 0;
815 #  }
816 # /* impgen.c ends here */
817       ;;
818     *)
819       allow_undefined=yes
820       ;;
821     esac
822     compile_command="$CC"
823     finalize_command="$CC"
824
825     compile_rpath=
826     finalize_rpath=
827     compile_shlibpath=
828     finalize_shlibpath=
829     convenience=
830     old_convenience=
831     deplibs=
832     linkopts=
833
834     if test -n "$shlibpath_var"; then
835       # get the directories listed in $shlibpath_var
836       eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
837     else
838       lib_search_path=
839     fi
840     # now prepend the system-specific ones
841     eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\"
842     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
843     
844     avoid_version=no
845     dlfiles=
846     dlprefiles=
847     dlself=no
848     export_dynamic=no
849     export_symbols=
850     export_symbols_regex=
851     generated=
852     libobjs=
853     link_against_libtool_libs=
854     ltlibs=
855     module=no
856     objs=
857     prefer_static_libs=no
858     preload=no
859     prev=
860     prevarg=
861     release=
862     rpath=
863     xrpath=
864     perm_rpath=
865     temp_rpath=
866     thread_safe=no
867     vinfo=
868
869     # We need to know -static, to get the right output filenames.
870     for arg
871     do
872       case "$arg" in
873       -all-static | -static)
874         if test "X$arg" = "X-all-static"; then
875           if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
876             $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
877           fi
878           if test -n "$link_static_flag"; then
879             dlopen_self=$dlopen_self_static
880           fi
881         else
882           if test -z "$pic_flag" && test -n "$link_static_flag"; then
883             dlopen_self=$dlopen_self_static
884           fi
885         fi
886         build_libtool_libs=no
887         build_old_libs=yes
888         prefer_static_libs=yes
889         break
890         ;;
891       esac
892     done
893
894     # See if our shared archives depend on static archives.
895     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
896
897     # Go through the arguments, transforming them on the way.
898     while test $# -gt 0; do
899       arg="$1"
900       shift
901
902       # If the previous option needs an argument, assign it.
903       if test -n "$prev"; then
904         case "$prev" in
905         output)
906           compile_command="$compile_command @OUTPUT@"
907           finalize_command="$finalize_command @OUTPUT@"
908           ;;
909         esac
910
911         case "$prev" in
912         dlfiles|dlprefiles)
913           if test "$preload" = no; then
914             # Add the symbol object into the linking commands.
915             compile_command="$compile_command @SYMFILE@"
916             finalize_command="$finalize_command @SYMFILE@"
917             preload=yes
918           fi
919           case "$arg" in
920           *.la | *.lo) ;;  # We handle these cases below.
921           force)
922             if test "$dlself" = no; then
923               dlself=needless
924               export_dynamic=yes
925             fi
926             prev=
927             continue
928             ;;
929           self)
930             if test "$prev" = dlprefiles; then
931               dlself=yes
932             elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
933               dlself=yes
934             else
935               dlself=needless
936               export_dynamic=yes
937             fi
938             prev=
939             continue
940             ;;
941           *)
942             if test "$prev" = dlfiles; then
943               dlfiles="$dlfiles $arg"
944             else
945               dlprefiles="$dlprefiles $arg"
946             fi
947             prev=
948             ;;
949           esac
950           ;;
951         expsyms)
952           export_symbols="$arg"
953           if test ! -f "$arg"; then
954             $echo "$modename: symbol file \`$arg' does not exist"
955             exit 1
956           fi
957           prev=
958           continue
959           ;;
960         expsyms_regex)
961           export_symbols_regex="$arg"
962           prev=
963           continue
964           ;;
965         release)
966           release="-$arg"
967           prev=
968           continue
969           ;;
970         rpath | xrpath)
971           # We need an absolute path.
972           case "$arg" in
973           [\\/]* | [A-Za-z]:[\\/]*) ;;
974           *)
975             $echo "$modename: only absolute run-paths are allowed" 1>&2
976             exit 1
977             ;;
978           esac
979           if test "$prev" = rpath; then
980             case "$rpath " in
981             *" $arg "*) ;;
982             *) rpath="$rpath $arg" ;;
983             esac
984           else
985             case "$xrpath " in
986             *" $arg "*) ;;
987             *) xrpath="$xrpath $arg" ;;
988             esac
989           fi
990           prev=
991           continue
992           ;;
993         *)
994           eval "$prev=\"\$arg\""
995           prev=
996           continue
997           ;;
998         esac
999       fi
1000
1001       prevarg="$arg"
1002
1003       case "$arg" in
1004       -all-static)
1005         if test -n "$link_static_flag"; then
1006           compile_command="$compile_command $link_static_flag"
1007           finalize_command="$finalize_command $link_static_flag"
1008         fi
1009         continue
1010         ;;
1011
1012       -allow-undefined)
1013         # FIXME: remove this flag sometime in the future.
1014         $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1015         continue
1016         ;;
1017
1018       -avoid-version)
1019         avoid_version=yes
1020         continue
1021         ;;
1022
1023       -dlopen)
1024         prev=dlfiles
1025         continue
1026         ;;
1027
1028       -dlpreopen)
1029         prev=dlprefiles
1030         continue
1031         ;;
1032
1033       -export-dynamic)
1034         export_dynamic=yes
1035         continue
1036         ;;
1037
1038       -export-symbols | -export-symbols-regex)
1039         if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1040           $echo "$modename: not more than one -exported-symbols argument allowed"
1041           exit 1
1042         fi
1043         if test "X$arg" = "X-export-symbols"; then
1044           prev=expsyms
1045         else
1046           prev=expsyms_regex
1047         fi
1048         continue
1049         ;;
1050
1051       -L*)
1052         dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1053         # We need an absolute path.
1054         case "$dir" in
1055         [\\/]* | [A-Za-z]:[\\/]*) ;;
1056         *)
1057           absdir=`cd "$dir" && pwd`
1058           if test -z "$absdir"; then
1059             $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
1060             $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
1061             absdir="$dir"
1062           fi
1063           dir="$absdir"
1064           ;;
1065         esac
1066         case " $deplibs " in
1067         *" $arg "*) ;;
1068         *) deplibs="$deplibs $arg";;
1069         esac
1070         case " $lib_search_path " in
1071         *" $dir "*) ;;
1072         *) lib_search_path="$lib_search_path $dir";;
1073         esac
1074         case "$host" in
1075         *-*-cygwin* | *-*-mingw* | *-*-os2*)
1076           dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
1077           case ":$dllsearchpath:" in
1078           ::) dllsearchpath="$dllsearchdir";;
1079           *":$dllsearchdir:"*) ;;
1080           *) dllsearchpath="$dllsearchpath:$dllsearchdir";;
1081           esac
1082           ;;
1083         esac
1084         ;;
1085
1086       -l*)
1087         if test "$arg" = "-lc"; then
1088           case "$host" in
1089           *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
1090             # These systems don't actually have c library (as such)
1091             continue
1092             ;;
1093           esac
1094         elif test "$arg" = "-lm"; then
1095           case "$host" in
1096           *-*-cygwin* | *-*-beos*)
1097             # These systems don't actually have math library (as such)
1098             continue
1099             ;;
1100           esac
1101         fi
1102         deplibs="$deplibs $arg"
1103         ;;
1104
1105       -module)
1106         module=yes
1107         continue
1108         ;;
1109
1110       -no-undefined)
1111         allow_undefined=no
1112         continue
1113         ;;
1114
1115       -o) prev=output ;;
1116
1117       -release)
1118         prev=release
1119         continue
1120         ;;
1121
1122       -rpath)
1123         prev=rpath
1124         continue
1125         ;;
1126
1127       -R)
1128         prev=xrpath
1129         continue
1130         ;;
1131
1132       -R*)
1133         dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1134         # We need an absolute path.
1135         case "$dir" in
1136         [\\/]* | [A-Za-z]:[\\/]*) ;;
1137         *)
1138           $echo "$modename: only absolute run-paths are allowed" 1>&2
1139           exit 1
1140           ;;
1141         esac
1142         case "$xrpath " in
1143         *" $dir "*) ;;
1144         *) xrpath="$xrpath $dir" ;;
1145         esac
1146         continue
1147         ;;
1148
1149       -static)
1150         # If we have no pic_flag, then this is the same as -all-static.
1151         if test -z "$pic_flag" && test -n "$link_static_flag"; then
1152           compile_command="$compile_command $link_static_flag"
1153           finalize_command="$finalize_command $link_static_flag"
1154         fi
1155         continue
1156         ;;
1157
1158       -thread-safe)
1159         thread_safe=yes
1160         continue
1161         ;;
1162
1163       -version-info)
1164         prev=vinfo
1165         continue
1166         ;;
1167
1168       # Some other compiler flag.
1169       -* | +*)
1170         # Unknown arguments in both finalize_command and compile_command need
1171         # to be aesthetically quoted because they are evaled later.
1172         arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1173         case "$arg" in
1174         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*)
1175           arg="\"$arg\""
1176           ;;
1177         esac
1178         ;;
1179
1180       *.o | *.obj | *.a | *.lib)
1181         # A standard object.
1182         objs="$objs $arg"
1183         ;;
1184
1185       *.lo)
1186         # A library object.
1187         if test "$prev" = dlfiles; then
1188           dlfiles="$dlfiles $arg"
1189           if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
1190             prev=
1191             continue
1192           else
1193             # If libtool objects are unsupported, then we need to preload.
1194             prev=dlprefiles
1195           fi
1196         fi
1197
1198         if test "$prev" = dlprefiles; then
1199           # Preload the old-style object.
1200           dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
1201           prev=
1202         fi
1203         libobjs="$libobjs $arg"
1204         ;;
1205
1206       *.la)
1207         # A libtool-controlled library.
1208
1209         dlname=
1210         libdir=
1211         library_names=
1212         old_library=
1213
1214         # Check to see that this really is a libtool archive.
1215         if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
1216         else
1217           $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
1218           exit 1
1219         fi
1220
1221         # If the library was installed with an old release of libtool,
1222         # it will not redefine variable installed.
1223         installed=yes
1224
1225         # Read the .la file
1226         # If there is no directory component, then add one.
1227         case "$arg" in
1228         */* | *\\*) . $arg ;;
1229         *) . ./$arg ;;
1230         esac
1231
1232         # Get the name of the library we link against.
1233         linklib=
1234         for l in $old_library $library_names; do
1235           linklib="$l"
1236         done
1237
1238         if test -z "$linklib"; then
1239           $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
1240           exit 1
1241         fi
1242
1243         # Find the relevant object directory and library name.
1244         name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
1245
1246         if test "X$installed" = Xyes; then
1247           dir="$libdir"
1248         else
1249           dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1250           if test "X$dir" = "X$arg"; then
1251             dir="$objdir"
1252           else
1253             dir="$dir/$objdir"
1254           fi
1255         fi
1256
1257         if test -n "$dependency_libs"; then
1258           # Extract -R and -L from dependency_libs
1259           temp_deplibs=
1260           for deplib in $dependency_libs; do
1261             case "$deplib" in
1262             -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
1263                  case " $rpath $xrpath " in
1264                  *" $temp_xrpath "*) ;;
1265                  *) xrpath="$xrpath $temp_xrpath";;
1266                  esac;;
1267             -L*) case "$compile_command $temp_deplibs " in
1268                  *" $deplib "*) ;;
1269                  *) temp_deplibs="$temp_deplibs $deplib";;
1270                  esac
1271                  temp_dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'`
1272                  case " $lib_search_path " in
1273                  *" $temp_dir "*) ;;
1274                  *) lib_search_path="$lib_search_path $temp_dir";;
1275                  esac
1276                  ;;
1277             *) temp_deplibs="$temp_deplibs $deplib";;
1278             esac
1279           done
1280           dependency_libs="$temp_deplibs"
1281         fi
1282
1283         if test -z "$libdir"; then
1284           # It is a libtool convenience library, so add in its objects.
1285           convenience="$convenience $dir/$old_library"
1286           old_convenience="$old_convenience $dir/$old_library"
1287           deplibs="$deplibs$dependency_libs"
1288           compile_command="$compile_command $dir/$old_library$dependency_libs"
1289           finalize_command="$finalize_command $dir/$old_library$dependency_libs"
1290           continue
1291         fi
1292
1293         # This library was specified with -dlopen.
1294         if test "$prev" = dlfiles; then
1295           dlfiles="$dlfiles $arg"
1296           if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
1297             # If there is no dlname, no dlopen support or we're linking statically,
1298             # we need to preload.
1299             prev=dlprefiles
1300           else
1301             # We should not create a dependency on this library, but we
1302             # may need any libraries it requires.
1303             compile_command="$compile_command$dependency_libs"
1304             finalize_command="$finalize_command$dependency_libs"
1305             prev=
1306             continue
1307           fi
1308         fi
1309
1310         # The library was specified with -dlpreopen.
1311         if test "$prev" = dlprefiles; then
1312           # Prefer using a static library (so that no silly _DYNAMIC symbols
1313           # are required to link).
1314           if test -n "$old_library"; then
1315             dlprefiles="$dlprefiles $dir/$old_library"
1316           else
1317             dlprefiles="$dlprefiles $dir/$linklib"
1318           fi
1319           prev=
1320         fi
1321
1322         if test -n "$library_names" &&
1323            { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
1324           link_against_libtool_libs="$link_against_libtool_libs $arg"
1325           if test -n "$shlibpath_var"; then
1326             # Make sure the rpath contains only unique directories.
1327             case "$temp_rpath " in
1328             *" $dir "*) ;;
1329             *) temp_rpath="$temp_rpath $dir" ;;
1330             esac
1331           fi
1332
1333           # We need an absolute path.
1334           case "$dir" in
1335           [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;;
1336           *)
1337             absdir=`cd "$dir" && pwd`
1338             if test -z "$absdir"; then
1339               $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
1340               $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
1341               absdir="$dir"
1342             fi
1343             ;;
1344           esac
1345           
1346           # This is the magic to use -rpath.
1347           # Skip directories that are in the system default run-time
1348           # search path, unless they have been requested with -R.
1349           case " $sys_lib_dlsearch_path " in
1350           *" $absdir "*) ;;
1351           *)
1352             case "$compile_rpath " in
1353             *" $absdir "*) ;;
1354             *) compile_rpath="$compile_rpath $absdir" 
1355             esac
1356             ;;
1357           esac
1358
1359           case " $sys_lib_dlsearch_path " in
1360           *" $libdir "*) ;;
1361           *)
1362             case "$finalize_rpath " in
1363             *" $libdir "*) ;;
1364             *) finalize_rpath="$finalize_rpath $libdir"
1365             esac
1366             ;;
1367           esac
1368
1369           lib_linked=yes
1370           case "$hardcode_action" in
1371           immediate | unsupported)
1372             if test "$hardcode_direct" = no; then
1373               compile_command="$compile_command $dir/$linklib"
1374               deplibs="$deplibs $dir/$linklib"
1375               case "$host" in
1376               *-*-cygwin* | *-*-mingw* | *-*-os2*)
1377                 dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
1378                 if test -n "$dllsearchpath"; then
1379                   dllsearchpath="$dllsearchpath:$dllsearchdir"
1380                 else
1381                   dllsearchpath="$dllsearchdir"
1382                 fi
1383                 ;;
1384               esac
1385             elif test "$hardcode_minus_L" = no; then
1386               case "$host" in
1387               *-*-sunos*)
1388                 compile_shlibpath="$compile_shlibpath$dir:"
1389                 ;;
1390               esac
1391               case "$compile_command " in
1392               *" -L$dir "*) ;;
1393               *) compile_command="$compile_command -L$dir";;
1394               esac
1395               compile_command="$compile_command -l$name"
1396               deplibs="$deplibs -L$dir -l$name"
1397             elif test "$hardcode_shlibpath_var" = no; then
1398               case ":$compile_shlibpath:" in
1399               *":$dir:"*) ;;
1400               *) compile_shlibpath="$compile_shlibpath$dir:";;
1401               esac
1402               compile_command="$compile_command -l$name"
1403               deplibs="$deplibs -l$name"
1404             else
1405               lib_linked=no
1406             fi
1407             ;;
1408
1409           relink)
1410             if test "$hardcode_direct" = yes; then
1411               compile_command="$compile_command $absdir/$linklib"
1412               deplibs="$deplibs $absdir/$linklib"
1413             elif test "$hardcode_minus_L" = yes; then
1414               case "$compile_command " in
1415               *" -L$absdir "*) ;;
1416               *) compile_command="$compile_command -L$absdir";;
1417               esac
1418               compile_command="$compile_command -l$name"
1419               deplibs="$deplibs -L$absdir -l$name"
1420             elif test "$hardcode_shlibpath_var" = yes; then
1421               case ":$compile_shlibpath:" in
1422               *":$absdir:"*) ;;
1423               *) compile_shlibpath="$compile_shlibpath$absdir:";;
1424               esac
1425               compile_command="$compile_command -l$name"
1426               deplibs="$deplibs -l$name"
1427             else
1428               lib_linked=no
1429             fi
1430             ;;
1431
1432           *)
1433             lib_linked=no
1434             ;;
1435           esac
1436
1437           if test "$lib_linked" != yes; then
1438             $echo "$modename: configuration error: unsupported hardcode properties"
1439             exit 1
1440           fi
1441
1442           # Finalize command for both is simple: just hardcode it.
1443           if test "$hardcode_direct" = yes; then
1444             finalize_command="$finalize_command $libdir/$linklib"
1445           elif test "$hardcode_minus_L" = yes; then
1446             case "$finalize_command " in
1447             *" -L$libdir "*) ;;
1448             *) finalize_command="$finalize_command -L$libdir";;
1449             esac
1450             finalize_command="$finalize_command -l$name"
1451           elif test "$hardcode_shlibpath_var" = yes; then
1452             case ":$finalize_shlibpath:" in
1453             *":$libdir:"*) ;;
1454             *) finalize_shlibpath="$finalize_shlibpath$libdir:";;
1455             esac
1456             finalize_command="$finalize_command -l$name"
1457           else
1458             # We cannot seem to hardcode it, guess we'll fake it.
1459             case "$finalize_command " in
1460             *" -L$dir "*) ;;
1461             *) finalize_command="$finalize_command -L$libdir";;
1462             esac
1463             finalize_command="$finalize_command -l$name"
1464           fi
1465         else
1466           # Transform directly to old archives if we don't build new libraries.
1467           if test -n "$pic_flag" && test -z "$old_library"; then
1468             $echo "$modename: cannot find static library for \`$arg'" 1>&2
1469             exit 1
1470           fi
1471
1472           # Here we assume that one of hardcode_direct or hardcode_minus_L
1473           # is not unsupported.  This is valid on all known static and
1474           # shared platforms.
1475           if test "$hardcode_direct" != unsupported; then
1476             test -n "$old_library" && linklib="$old_library"
1477             compile_command="$compile_command $dir/$linklib"
1478             finalize_command="$finalize_command $dir/$linklib"
1479           else
1480             case "$compile_command " in
1481             *" -L$dir "*) ;;
1482             *) compile_command="$compile_command -L$dir";;
1483             esac
1484             compile_command="$compile_command -l$name"
1485             case "$finalize_command " in
1486             *" -L$dir "*) ;;
1487             *) finalize_command="$finalize_command -L$dir";;
1488             esac
1489             finalize_command="$finalize_command -l$name"
1490           fi
1491         fi
1492
1493         # Add in any libraries that this one depends upon.
1494         compile_command="$compile_command$dependency_libs"
1495         finalize_command="$finalize_command$dependency_libs"
1496         continue
1497         ;;
1498
1499       # Some other compiler argument.
1500       *)
1501         # Unknown arguments in both finalize_command and compile_command need
1502         # to be aesthetically quoted because they are evaled later.
1503         arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1504         case "$arg" in
1505         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*)
1506           arg="\"$arg\""
1507           ;;
1508         esac
1509         ;;
1510       esac
1511
1512       # Now actually substitute the argument into the commands.
1513       if test -n "$arg"; then
1514         compile_command="$compile_command $arg"
1515         finalize_command="$finalize_command $arg"
1516       fi
1517     done
1518
1519     if test -n "$prev"; then
1520       $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1521       $echo "$help" 1>&2
1522       exit 1
1523     fi
1524
1525     if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
1526       eval arg=\"$export_dynamic_flag_spec\"
1527       compile_command="$compile_command $arg"
1528       finalize_command="$finalize_command $arg"
1529     fi
1530
1531     oldlibs=
1532     # calculate the name of the file, without its directory
1533     outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
1534     libobjs_save="$libobjs"
1535
1536     case "$output" in
1537     "")
1538       $echo "$modename: you must specify an output file" 1>&2
1539       $echo "$help" 1>&2
1540       exit 1
1541       ;;
1542
1543     *.a | *.lib)
1544       if test -n "$link_against_libtool_libs"; then
1545         $echo "$modename: error: cannot link libtool libraries into archives" 1>&2
1546         exit 1
1547       fi
1548
1549       if test -n "$deplibs"; then
1550         $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
1551       fi
1552
1553       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
1554         $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
1555       fi
1556
1557       if test -n "$rpath"; then
1558         $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
1559       fi
1560
1561       if test -n "$xrpath"; then
1562         $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
1563       fi
1564
1565       if test -n "$vinfo"; then
1566         $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
1567       fi
1568
1569       if test -n "$release"; then
1570         $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
1571       fi
1572
1573       if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1574         $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
1575       fi
1576
1577       # Now set the variables for building old libraries.
1578       build_libtool_libs=no
1579       oldlibs="$output"
1580       ;;
1581
1582     *.la)
1583       # Make sure we only generate libraries of the form `libNAME.la'.
1584       case "$outputname" in
1585       lib*)
1586         name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
1587         eval libname=\"$libname_spec\"
1588         ;;
1589       *)
1590         if test "$module" = no; then
1591           $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
1592           $echo "$help" 1>&2
1593           exit 1
1594         fi
1595         if test "$need_lib_prefix" != no; then
1596           # Add the "lib" prefix for modules if required
1597           name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
1598           eval libname=\"$libname_spec\"
1599         else
1600           libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
1601         fi
1602         ;;
1603       esac
1604
1605       output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
1606       if test "X$output_objdir" = "X$output"; then
1607         output_objdir="$objdir"
1608       else
1609         output_objdir="$output_objdir/$objdir"
1610       fi
1611
1612       if test -n "$objs"; then
1613         $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
1614         exit 1
1615       fi
1616
1617       # How the heck are we supposed to write a wrapper for a shared library?
1618       if test -n "$link_against_libtool_libs"; then
1619          $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
1620          exit 1
1621       fi
1622
1623       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
1624         $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
1625       fi
1626
1627       set dummy $rpath
1628       if test $# -gt 2; then
1629         $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
1630       fi
1631       install_libdir="$2"
1632
1633       oldlibs=
1634       if test -z "$rpath"; then
1635         if test "$build_libtool_libs" = yes; then
1636           # Building a libtool convenience library.
1637           libext=al
1638           oldlibs="$output_objdir/$libname.$libext $oldlibs"
1639           build_libtool_libs=convenience
1640           build_old_libs=yes
1641         fi
1642         dependency_libs="$deplibs"
1643
1644         if test -n "$vinfo"; then
1645           $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
1646         fi
1647
1648         if test -n "$release"; then
1649           $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
1650         fi
1651       else
1652
1653         # Parse the version information argument.
1654         IFS="${IFS=     }"; save_ifs="$IFS"; IFS=':'
1655         set dummy $vinfo 0 0 0
1656         IFS="$save_ifs"
1657
1658         if test -n "$8"; then
1659           $echo "$modename: too many parameters to \`-version-info'" 1>&2
1660           $echo "$help" 1>&2
1661           exit 1
1662         fi
1663
1664         current="$2"
1665         revision="$3"
1666         age="$4"
1667
1668         # Check that each of the things are valid numbers.
1669         case "$current" in
1670         0 | [1-9] | [1-9][0-9]*) ;;
1671         *)
1672           $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
1673           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
1674           exit 1
1675           ;;
1676         esac
1677
1678         case "$revision" in
1679         0 | [1-9] | [1-9][0-9]*) ;;
1680         *)
1681           $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
1682           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
1683           exit 1
1684           ;;
1685         esac
1686
1687         case "$age" in
1688         0 | [1-9] | [1-9][0-9]*) ;;
1689         *)
1690           $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
1691           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
1692           exit 1
1693           ;;
1694         esac
1695
1696         if test $age -gt $current; then
1697           $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
1698           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
1699           exit 1
1700         fi
1701
1702         # Calculate the version variables.
1703         major=
1704         versuffix=
1705         verstring=
1706         case "$version_type" in
1707         none) ;;
1708
1709         irix)
1710           major=`expr $current - $age + 1`
1711           versuffix="$major.$revision"
1712           verstring="sgi$major.$revision"
1713
1714           # Add in all the interfaces that we are compatible with.
1715           loop=$revision
1716           while test $loop != 0; do
1717             iface=`expr $revision - $loop`
1718             loop=`expr $loop - 1`
1719             verstring="sgi$major.$iface:$verstring"
1720           done
1721           ;;
1722
1723         linux)
1724           major=.`expr $current - $age`
1725           versuffix="$major.$age.$revision"
1726           ;;
1727
1728         osf)
1729           major=`expr $current - $age`
1730           versuffix=".$current.$age.$revision"
1731           verstring="$current.$age.$revision"
1732
1733           # Add in all the interfaces that we are compatible with.
1734           loop=$age
1735           while test $loop != 0; do
1736             iface=`expr $current - $loop`
1737             loop=`expr $loop - 1`
1738             verstring="$verstring:${iface}.0"
1739           done
1740
1741           # Make executables depend on our current version.
1742           verstring="$verstring:${current}.0"
1743           ;;
1744
1745         sunos)
1746           major=".$current"
1747           versuffix=".$current.$revision"
1748           ;;
1749
1750         freebsd-aout)
1751           major=".$current"
1752           versuffix=".$current.$revision";
1753           ;;
1754
1755         freebsd-elf)
1756           major=".$current"
1757           versuffix=".$current";
1758           ;;
1759
1760         windows)
1761           # Like Linux, but with '-' rather than '.', since we only
1762           # want one extension on Windows 95.
1763           major=`expr $current - $age`
1764           versuffix="-$major-$age-$revision"
1765           ;;
1766
1767         *)
1768           $echo "$modename: unknown library version type \`$version_type'" 1>&2
1769           echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
1770           exit 1
1771           ;;
1772         esac
1773
1774         # Clear the version info if we defaulted, and they specified a release.
1775         if test -z "$vinfo" && test -n "$release"; then
1776           major=
1777           verstring="0.0"
1778           if test "$need_version" = no; then
1779             versuffix=
1780           else
1781             versuffix=".0.0"
1782           fi
1783         fi
1784
1785         # Remove version info from name if versioning should be avoided
1786         if test "$avoid_version" = yes && test "$need_version" = no; then
1787           major=
1788           versuffix=
1789           verstring=""
1790         fi
1791         
1792         # Check to see if the archive will have undefined symbols.
1793         if test "$allow_undefined" = yes; then
1794           if test "$allow_undefined_flag" = unsupported; then
1795             $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
1796             build_libtool_libs=no
1797             build_old_libs=yes
1798           fi
1799         else
1800           # Don't allow undefined symbols.
1801           allow_undefined_flag="$no_undefined_flag"
1802         fi
1803
1804         dependency_libs="$deplibs"
1805         case "$host" in
1806         *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
1807           # these systems don't actually have a c library (as such)!
1808           ;;
1809         *)
1810           # Add libc to deplibs on all other systems.
1811           deplibs="$deplibs -lc"
1812           ;;
1813         esac
1814       fi
1815
1816       # Create the output directory, or remove our outputs if we need to.
1817       if test -d $output_objdir; then
1818         $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
1819         $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
1820       else
1821         $show "$mkdir $output_objdir"
1822         $run $mkdir $output_objdir
1823         status=$?
1824         if test $status -ne 0 && test ! -d $output_objdir; then
1825           exit $status
1826         fi
1827       fi
1828
1829       # Now set the variables for building old libraries.
1830       if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
1831         oldlibs="$oldlibs $output_objdir/$libname.$libext"
1832
1833         # Transform .lo files to .o files.
1834         oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
1835       fi
1836
1837       if test "$build_libtool_libs" = yes; then
1838         # Transform deplibs into only deplibs that can be linked in shared.
1839         name_save=$name
1840         libname_save=$libname
1841         release_save=$release
1842         versuffix_save=$versuffix
1843         major_save=$major
1844         # I'm not sure if I'm treating the release correctly.  I think
1845         # release should show up in the -l (ie -lgmp5) so we don't want to
1846         # add it in twice.  Is that correct?
1847         release=""
1848         versuffix=""
1849         major=""
1850         newdeplibs=
1851         droppeddeps=no
1852         case "$deplibs_check_method" in
1853         pass_all)
1854           # Don't check for shared/static.  Everything works.
1855           # This might be a little naive.  We might want to check
1856           # whether the library exists or not.  But this is on
1857           # osf3 & osf4 and I'm not really sure... Just
1858           # implementing what was already the behaviour.
1859           newdeplibs=$deplibs
1860           ;;
1861         test_compile)
1862           # This code stresses the "libraries are programs" paradigm to its
1863           # limits. Maybe even breaks it.  We compile a program, linking it
1864           # against the deplibs as a proxy for the library.  Then we can check
1865           # whether they linked in statically or dynamically with ldd.
1866           $rm conftest.c
1867           cat > conftest.c <<EOF
1868           int main() { return 0; }
1869 EOF
1870           $rm conftest
1871           $C_compiler -o conftest conftest.c $deplibs
1872           if test $? -eq 0 ; then
1873             ldd_output=`ldd conftest`
1874             for i in $deplibs; do
1875               name="`expr $i : '-l\(.*\)'`"
1876               # If $name is empty we are operating on a -L argument.
1877               if test "$name" != "" ; then
1878                 libname=`eval \\$echo \"$libname_spec\"`
1879                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
1880                 set dummy $deplib_matches
1881                 deplib_match=$2
1882                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
1883                   newdeplibs="$newdeplibs $i"
1884                 else
1885                   droppeddeps=yes
1886                   echo
1887                   echo "*** Warning: This library needs some functionality provided by $i."
1888                   echo "*** I have the capability to make that library automatically link in when"
1889                   echo "*** you link to this library.  But I can only do this if you have a"
1890                   echo "*** shared version of the library, which you do not appear to have."
1891                 fi
1892               else
1893                 newdeplibs="$newdeplibs $i"
1894               fi
1895             done
1896           else
1897             # Error occured in the first compile.  Let's try to salvage the situation:
1898             # Compile a seperate program for each library.
1899             for i in $deplibs; do
1900               name="`expr $i : '-l\(.*\)'`"
1901              # If $name is empty we are operating on a -L argument.
1902               if test "$name" != "" ; then
1903                 $rm conftest
1904                 $C_compiler -o conftest conftest.c $i
1905                 # Did it work?
1906                 if test $? -eq 0 ; then
1907                   ldd_output=`ldd conftest`
1908                   libname=`eval \\$echo \"$libname_spec\"`
1909                   deplib_matches=`eval \\$echo \"$library_names_spec\"`
1910                   set dummy $deplib_matches
1911                   deplib_match=$2
1912                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
1913                     newdeplibs="$newdeplibs $i"
1914                   else
1915                     droppeddeps=yes
1916                     echo
1917                     echo "*** Warning: This library needs some functionality provided by $i."
1918                     echo "*** I have the capability to make that library automatically link in when"
1919                     echo "*** you link to this library.  But I can only do this if you have a"
1920                     echo "*** shared version of the library, which you do not appear to have."
1921                   fi
1922                 else
1923                   droppeddeps=yes
1924                   echo
1925                   echo "*** Warning!  Library $i is needed by this library but I was not able to"
1926                   echo "***  make it link in!  You will probably need to install it or some"
1927                   echo "*** library that it depends on before this library will be fully"
1928                   echo "*** functional.  Installing it before continuing would be even better."
1929                 fi
1930               else
1931                 newdeplibs="$newdeplibs $i"
1932               fi
1933             done
1934           fi
1935           ;;
1936         file_magic*)
1937           set dummy $deplibs_check_method
1938           file_magic_regex="`expr \"$deplibs_check_method\" : \"$2 \(.*\)\"`"
1939           for a_deplib in $deplibs; do
1940             name="`expr $a_deplib : '-l\(.*\)'`"
1941             # If $name is empty we are operating on a -L argument.
1942             if test "$name" != "" ; then
1943               libname=`eval \\$echo \"$libname_spec\"`
1944               for i in $lib_search_path; do
1945                     potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
1946                     for potent_lib in $potential_libs; do
1947                       # Follow soft links.
1948                       if ls -lLd "$potent_lib" 2>/dev/null \
1949                          | grep " -> " >/dev/null; then
1950                         continue 
1951                       fi
1952                       # The statement above tries to avoid entering an
1953                       # endless loop below, in case of cyclic links.
1954                       # We might still enter an endless loop, since a link
1955                       # loop can be closed while we follow links,
1956                       # but so what?
1957                       potlib="$potent_lib"
1958                       while test -h "$potlib" 2>/dev/null; do
1959                         potliblink=`ls -ld $potlib | sed 's/.* -> //'`
1960                         case "$potliblink" in
1961                         [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
1962                         *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
1963                         esac
1964                       done
1965                       if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
1966                          | sed 10q \
1967                          | egrep "$file_magic_regex" > /dev/null; then
1968                         newdeplibs="$newdeplibs $a_deplib"
1969                         a_deplib=""
1970                         break 2
1971                       fi
1972                     done
1973               done
1974               if test -n "$a_deplib" ; then
1975                 droppeddeps=yes
1976                 echo
1977                 echo "*** Warning: This library needs some functionality provided by $a_deplib."
1978                 echo "*** I have the capability to make that library automatically link in when"
1979                 echo "*** you link to this library.  But I can only do this if you have a"
1980                 echo "*** shared version of the library, which you do not appear to have."
1981               fi
1982             else
1983               # Add a -L argument.
1984               newdeplibs="$newdeplibs $a_deplib"
1985             fi
1986           done # Gone through all deplibs.
1987           ;;
1988         none | unknown | *)
1989           newdeplibs=""
1990           if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
1991                -e 's/ -[LR][^ ]*//g' -e 's/[    ]//g' |
1992              grep . >/dev/null; then
1993             echo
1994             if test "X$deplibs_check_method" = "Xnone"; then
1995               echo "*** Warning: inter-library dependencies are not supported in this platform."
1996             else
1997               echo "*** Warning: inter-library dependencies are not known to be supported."
1998             fi
1999             echo "*** All declared inter-library dependencies are being dropped."
2000             droppeddeps=yes
2001           fi
2002           ;;
2003         esac
2004         versuffix=$versuffix_save
2005         major=$major_save
2006         release=$release_save
2007         libname=$libname_save
2008         name=$name_save
2009
2010         if test "$droppeddeps" = yes; then
2011           if test "$module" = yes; then
2012             echo
2013             echo "*** Warning: libtool could not satisfy all declared inter-library"
2014             echo "*** dependencies of module $libname.  Therefore, libtool will create"
2015             echo "*** a static module, that should work as long as the dlopening"
2016             echo "*** application is linked with the -dlopen flag."
2017             if test -z "$global_symbol_pipe"; then
2018               echo
2019               echo "*** However, this would only work if libtool was able to extract symbol"
2020               echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2021               echo "*** not find such a program.  So, this module is probably useless."
2022               echo "*** \`nm' from GNU binutils and a full rebuild may help."
2023             fi
2024             if test "$build_old_libs" = no; then
2025               oldlibs="$output_objdir/$libname.$libext"
2026               build_libtool_libs=module
2027               build_old_libs=yes
2028             else
2029               build_libtool_libs=no
2030             fi
2031           else
2032             echo "*** The inter-library dependencies that have been dropped here will be"
2033             echo "*** automatically added whenever a program is linked with this library"
2034             echo "*** or is declared to -dlopen it."
2035           fi
2036         fi
2037         # Done checking deplibs!
2038         deplibs=$newdeplibs
2039       fi
2040
2041       # All the library-specific variables (install_libdir is set above).
2042       library_names=
2043       old_library=
2044       dlname=
2045       
2046       # Test again, we may have decided not to build it any more
2047       if test "$build_libtool_libs" = yes; then
2048         # Get the real and link names of the library.
2049         eval library_names=\"$library_names_spec\"
2050         set dummy $library_names
2051         realname="$2"
2052         shift; shift
2053
2054         if test -n "$soname_spec"; then
2055           eval soname=\"$soname_spec\"
2056         else
2057           soname="$realname"
2058         fi
2059
2060         lib="$output_objdir/$realname"
2061         for link
2062         do
2063           linknames="$linknames $link"
2064         done
2065
2066         # Ensure that we have .o objects for linkers which dislike .lo
2067         # (e.g. aix) incase we are running --disable-static
2068         for obj in $libobjs; do
2069           oldobj=`$echo "X$obj" | $Xsed -e "$lo2o"`
2070           if test ! -f $oldobj; then
2071             $show "${LN_S} $obj $oldobj"
2072             $run ${LN_S} $obj $oldobj || exit $?
2073           fi
2074         done
2075
2076         # Use standard objects if they are pic
2077         test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2078
2079         # Prepare the list of exported symbols
2080         if test -z "$export_symbols"; then
2081           if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
2082             $show "generating symbol list for \`$libname.la'"
2083             export_symbols="$output_objdir/$libname.exp"
2084             $run $rm $export_symbols
2085             eval cmds=\"$export_symbols_cmds\"
2086             IFS="${IFS=         }"; save_ifs="$IFS"; IFS='~'
2087             for cmd in $cmds; do
2088               IFS="$save_ifs"
2089               $show "$cmd"
2090               $run eval "$cmd" || exit $?
2091             done
2092             IFS="$save_ifs"
2093             if test -n "$export_symbols_regex"; then
2094               $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
2095               $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
2096               $show "$mv \"${export_symbols}T\" \"$export_symbols\""
2097               $run eval '$mv "${export_symbols}T" "$export_symbols"'
2098             fi
2099           fi
2100         fi
2101
2102         if test -n "$export_symbols" && test -n "$include_expsyms"; then
2103           $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
2104         fi
2105
2106         if test -n "$convenience"; then
2107           if test -n "$whole_archive_flag_spec"; then
2108             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
2109           else
2110             gentop="$output_objdir/${outputname}x"
2111             $show "${rm}r $gentop"
2112             $run ${rm}r "$gentop"
2113             $show "mkdir $gentop"
2114             $run mkdir "$gentop"
2115             status=$?
2116             if test $status -ne 0 && test ! -d "$gentop"; then
2117               exit $status
2118             fi
2119             generated="$generated $gentop"
2120
2121             for xlib in $convenience; do
2122               # Extract the objects.
2123               case "$xlib" in
2124               [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
2125               *) xabs=`pwd`"/$xlib" ;;
2126               esac
2127               xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
2128               xdir="$gentop/$xlib"
2129
2130               $show "${rm}r $xdir"
2131               $run ${rm}r "$xdir"
2132               $show "mkdir $xdir"
2133               $run mkdir "$xdir"
2134               status=$?
2135               if test $status -ne 0 && test ! -d "$xdir"; then
2136                 exit $status
2137               fi
2138               $show "(cd $xdir && $AR x $xabs)"
2139               $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
2140
2141               libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
2142             done
2143           fi
2144         fi
2145
2146         if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
2147           eval flag=\"$thread_safe_flag_spec\"
2148           linkopts="$linkopts $flag"
2149         fi
2150
2151         # Do each of the archive commands.
2152         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
2153           eval cmds=\"$archive_expsym_cmds\"
2154         else
2155           eval cmds=\"$archive_cmds\"
2156         fi
2157         IFS="${IFS=     }"; save_ifs="$IFS"; IFS='~'
2158         for cmd in $cmds; do
2159           IFS="$save_ifs"
2160           $show "$cmd"
2161           $run eval "$cmd" || exit $?
2162         done
2163         IFS="$save_ifs"
2164
2165         # Create links to the real library.
2166         for linkname in $linknames; do
2167           if test "$realname" != "$linkname"; then
2168             $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
2169             $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
2170           fi
2171         done
2172
2173         # If -module or -export-dynamic was specified, set the dlname.
2174         if test "$module" = yes || test "$export_dynamic" = yes; then
2175           # On all known operating systems, these are identical.
2176           dlname="$soname"
2177         fi
2178       fi
2179       ;;
2180
2181     *.lo | *.o | *.obj)
2182       if test -n "$link_against_libtool_libs"; then
2183         $echo "$modename: error: cannot link libtool libraries into objects" 1>&2
2184         exit 1
2185       fi
2186
2187       if test -n "$deplibs"; then
2188         $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
2189       fi
2190
2191       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2192         $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
2193       fi
2194
2195       if test -n "$rpath"; then
2196         $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
2197       fi
2198
2199       if test -n "$xrpath"; then
2200         $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
2201       fi
2202
2203       if test -n "$vinfo"; then
2204         $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
2205       fi
2206
2207       if test -n "$release"; then
2208         $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
2209       fi
2210
2211       case "$output" in
2212       *.lo)
2213         if test -n "$objs"; then
2214           $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
2215           exit 1
2216         fi
2217         libobj="$output"
2218         obj=`$echo "X$output" | $Xsed -e "$lo2o"`
2219         ;;
2220       *)
2221         libobj=
2222         obj="$output"
2223         ;;
2224       esac
2225
2226       # Delete the old objects.
2227       $run $rm $obj $libobj
2228
2229       # Objects from convenience libraries.  This assumes
2230       # single-version convenience libraries.  Whenever we create
2231       # different ones for PIC/non-PIC, this we'll have to duplicate
2232       # the extraction.
2233       reload_conv_objs=
2234       gentop=
2235       # reload_cmds runs $LD directly, so let us get rid of
2236       # -Wl from whole_archive_flag_spec
2237       wl= 
2238
2239       if test -n "$convenience"; then
2240         if test -n "$whole_archive_flag_spec"; then
2241           eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
2242         else
2243           gentop="$output_objdir/${obj}x"
2244           $show "${rm}r $gentop"
2245           $run ${rm}r "$gentop"
2246           $show "mkdir $gentop"
2247           $run mkdir "$gentop"
2248           status=$?
2249           if test $status -ne 0 && test ! -d "$gentop"; then
2250             exit $status
2251           fi
2252           generated="$generated $gentop"
2253
2254           for xlib in $convenience; do
2255             # Extract the objects.
2256             case "$xlib" in
2257             [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
2258             *) xabs=`pwd`"/$xlib" ;;
2259             esac
2260             xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
2261             xdir="$gentop/$xlib"
2262
2263             $show "${rm}r $xdir"
2264             $run ${rm}r "$xdir"
2265             $show "mkdir $xdir"
2266             $run mkdir "$xdir"
2267             status=$?
2268             if test $status -ne 0 && test ! -d "$xdir"; then
2269               exit $status
2270             fi
2271             $show "(cd $xdir && $AR x $xabs)"
2272             $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
2273
2274             reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
2275           done
2276         fi
2277       fi
2278
2279       # Create the old-style object.
2280       reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs"
2281
2282       output="$obj"
2283       eval cmds=\"$reload_cmds\"
2284       IFS="${IFS=       }"; save_ifs="$IFS"; IFS='~'
2285       for cmd in $cmds; do
2286         IFS="$save_ifs"
2287         $show "$cmd"
2288         $run eval "$cmd" || exit $?
2289       done
2290       IFS="$save_ifs"
2291
2292       # Exit if we aren't doing a library object file.
2293       if test -z "$libobj"; then
2294         if test -n "$gentop"; then
2295           $show "${rm}r $gentop"
2296           $run ${rm}r $gentop
2297         fi
2298
2299         exit 0
2300       fi
2301
2302       if test "$build_libtool_libs" != yes; then
2303         if test -n "$gentop"; then
2304           $show "${rm}r $gentop"
2305           $run ${rm}r $gentop
2306         fi
2307
2308         # Create an invalid libtool object if no PIC, so that we don't
2309         # accidentally link it into a program.
2310         $show "echo timestamp > $libobj"
2311         $run eval "echo timestamp > $libobj" || exit $?
2312         exit 0
2313       fi
2314
2315       if test -n "$pic_flag"; then
2316         # Only do commands if we really have different PIC objects.
2317         reload_objs="$libobjs $reload_conv_objs"
2318         output="$libobj"
2319         eval cmds=\"$reload_cmds\"
2320         IFS="${IFS=     }"; save_ifs="$IFS"; IFS='~'
2321         for cmd in $cmds; do
2322           IFS="$save_ifs"
2323           $show "$cmd"
2324           $run eval "$cmd" || exit $?
2325         done
2326         IFS="$save_ifs"
2327       else
2328         # Just create a symlink.
2329         $show $rm $libobj
2330         $run $rm $libobj
2331         $show "$LN_S $obj $libobj"
2332         $run $LN_S $obj $libobj || exit $?
2333       fi
2334
2335       if test -n "$gentop"; then
2336         $show "${rm}r $gentop"
2337         $run ${rm}r $gentop
2338       fi
2339
2340       exit 0
2341       ;;
2342
2343     # Anything else should be a program.
2344     *)
2345       if test -n "$vinfo"; then
2346         $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
2347       fi
2348
2349       if test -n "$release"; then
2350         $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
2351       fi
2352
2353       if test "$preload" = yes; then
2354         if test "$dlopen" = unknown && test "$dlopen_self" = unknown &&
2355            test "$dlopen_self_static" = unknown; then
2356           $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
2357         fi 
2358       fi
2359     
2360       if test -n "$rpath$xrpath"; then
2361         # If the user specified any rpath flags, then add them.
2362         for libdir in $rpath $xrpath; do
2363           # This is the magic to use -rpath.
2364           case "$compile_rpath " in
2365           *" $libdir "*) ;;
2366           *) compile_rpath="$compile_rpath $libdir" ;;
2367           esac
2368           case "$finalize_rpath " in
2369           *" $libdir "*) ;;
2370           *) finalize_rpath="$finalize_rpath $libdir" ;;
2371           esac
2372         done
2373       fi
2374
2375       # Now hardcode the library paths
2376       rpath=
2377       hardcode_libdirs=
2378       for libdir in $compile_rpath $finalize_rpath; do
2379         if test -n "$hardcode_libdir_flag_spec"; then
2380           if test -n "$hardcode_libdir_separator"; then
2381             if test -z "$hardcode_libdirs"; then
2382               hardcode_libdirs="$libdir"
2383             else
2384               # Just accumulate the unique libdirs.
2385               case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
2386               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
2387                 ;;
2388               *)
2389                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
2390                 ;;
2391               esac
2392             fi
2393           else
2394             eval flag=\"$hardcode_libdir_flag_spec\"
2395             rpath="$rpath $flag"
2396           fi
2397         elif test -n "$runpath_var"; then
2398           case "$perm_rpath " in
2399           *" $libdir "*) ;;
2400           *) perm_rpath="$perm_rpath $libdir" ;;
2401           esac
2402         fi
2403       done
2404       # Substitute the hardcoded libdirs into the rpath.
2405       if test -n "$hardcode_libdir_separator" &&
2406          test -n "$hardcode_libdirs"; then
2407         libdir="$hardcode_libdirs"
2408         eval rpath=\" $hardcode_libdir_flag_spec\"
2409       fi
2410       compile_rpath="$rpath"
2411
2412       rpath=
2413       hardcode_libdirs=
2414       for libdir in $finalize_rpath; do
2415         if test -n "$hardcode_libdir_flag_spec"; then
2416           if test -n "$hardcode_libdir_separator"; then
2417             if test -z "$hardcode_libdirs"; then
2418               hardcode_libdirs="$libdir"
2419             else
2420               # Just accumulate the unique libdirs.
2421               case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
2422               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
2423                 ;;
2424               *)
2425                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
2426                 ;;
2427               esac
2428             fi
2429           else
2430             eval flag=\"$hardcode_libdir_flag_spec\"
2431             rpath="$rpath $flag"
2432           fi
2433         elif test -n "$runpath_var"; then
2434           case "$finalize_perm_rpath " in
2435           *" $libdir "*) ;;
2436           *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
2437           esac
2438         fi
2439       done
2440       # Substitute the hardcoded libdirs into the rpath.
2441       if test -n "$hardcode_libdir_separator" &&
2442          test -n "$hardcode_libdirs"; then
2443         libdir="$hardcode_libdirs"
2444         eval rpath=\" $hardcode_libdir_flag_spec\"
2445       fi
2446       finalize_rpath="$rpath"
2447
2448       output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
2449       if test "X$output_objdir" = "X$output"; then
2450         output_objdir="$objdir"
2451       else
2452         output_objdir="$output_objdir/$objdir"
2453       fi
2454
2455       # Create the binary in the object directory, then wrap it.
2456       if test ! -d $output_objdir; then
2457         $show "$mkdir $output_objdir"
2458         $run $mkdir $output_objdir
2459         status=$?
2460         if test $status -ne 0 && test ! -d $output_objdir; then
2461           exit $status
2462         fi
2463       fi
2464
2465       if test -n "$libobjs" && test "$build_old_libs" = yes; then
2466         # Transform all the library objects into standard objects.
2467         compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2468         finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2469       fi
2470
2471       dlsyms=
2472       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2473         if test -n "$NM" && test -n "$global_symbol_pipe"; then
2474           dlsyms="${outputname}S.c"
2475         else
2476           $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
2477         fi
2478       fi
2479
2480       if test -n "$dlsyms"; then
2481         case "$dlsyms" in
2482         "") ;;
2483         *.c)
2484           # Discover the nlist of each of the dlfiles.
2485           nlist="$output_objdir/${outputname}.nm"
2486
2487           $show "$rm $nlist ${nlist}S ${nlist}T"
2488           $run $rm "$nlist" "${nlist}S" "${nlist}T"
2489
2490           # Parse the name list into a source file.
2491           $show "creating $output_objdir/$dlsyms"
2492
2493           test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
2494 /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
2495 /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
2496
2497 #ifdef __cplusplus
2498 extern \"C\" {
2499 #endif
2500
2501 /* Prevent the only kind of declaration conflicts we can make. */
2502 #define lt_preloaded_symbols some_other_symbol
2503
2504 /* External symbol declarations for the compiler. */\
2505 "
2506
2507           if test "$dlself" = yes; then
2508             $show "generating symbol list for \`$output'"
2509
2510             test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
2511
2512             # Add our own program objects to the symbol list.
2513             progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2514             for arg in $progfiles; do
2515               $show "extracting global C symbols from \`$arg'"
2516               $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
2517             done
2518
2519             if test -n "$exclude_expsyms"; then
2520               $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2521               $run eval '$mv "$nlist"T "$nlist"'
2522             fi
2523             
2524             if test -n "$export_symbols_regex"; then
2525               $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2526               $run eval '$mv "$nlist"T "$nlist"'
2527             fi
2528
2529             # Prepare the list of exported symbols
2530             if test -z "$export_symbols"; then
2531               export_symbols="$output_objdir/$output.exp"
2532               $run $rm $export_symbols
2533               $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2534             else
2535               $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
2536               $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
2537               $run eval 'mv "$nlist"T "$nlist"'
2538             fi
2539           fi
2540
2541           for arg in $dlprefiles; do
2542             $show "extracting global C symbols from \`$arg'"
2543             name=`echo "$arg" | sed -e 's%^.*/%%'`
2544             $run eval 'echo ": $name " >> "$nlist"'
2545             $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
2546           done
2547
2548           if test -z "$run"; then
2549             # Make sure we have at least an empty file.
2550             test -f "$nlist" || : > "$nlist"
2551
2552             if test -n "$exclude_expsyms"; then
2553               egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2554               $mv "$nlist"T "$nlist"
2555             fi
2556
2557             # Try sorting and uniquifying the output.
2558             if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
2559               :
2560             else
2561               grep -v "^: " < "$nlist" > "$nlist"S
2562             fi
2563
2564             if test -f "$nlist"S; then
2565               eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
2566             else
2567               echo '/* NONE */' >> "$output_objdir/$dlsyms"
2568             fi
2569
2570             $echo >> "$output_objdir/$dlsyms" "\
2571
2572 #undef lt_preloaded_symbols
2573
2574 #if defined (__STDC__) && __STDC__
2575 # define lt_ptr_t void *
2576 #else
2577 # define lt_ptr_t char *
2578 # define const
2579 #endif
2580
2581 /* The mapping between symbol names and symbols. */
2582 const struct {
2583   const char *name;
2584   lt_ptr_t address;
2585 }
2586 lt_preloaded_symbols[] =
2587 {\
2588 "
2589
2590             sed -n -e 's/^: \([^ ]*\) $/  {\"\1\", (lt_ptr_t) 0},/p' \
2591                 -e 's/^. \([^ ]*\) \([^ ]*\)$/  {"\2", (lt_ptr_t) \&\2},/p' \
2592                   < "$nlist" >> "$output_objdir/$dlsyms"
2593
2594             $echo >> "$output_objdir/$dlsyms" "\
2595   {0, (lt_ptr_t) 0}
2596 };
2597
2598 /* This works around a problem in FreeBSD linker */
2599 #ifdef FREEBSD_WORKAROUND
2600 static const void *lt_preloaded_setup() {
2601   return lt_preloaded_symbols;
2602 }
2603 #endif
2604
2605 #ifdef __cplusplus
2606 }
2607 #endif\
2608 "
2609           fi
2610
2611           pic_flag_for_symtable=
2612           case "$host" in
2613           # compiling the symbol table file with pic_flag works around
2614           # a FreeBSD bug that causes programs to crash when -lm is
2615           # linked before any other PIC object.  But we must not use
2616           # pic_flag when linking with -static.  The problem exists in
2617           # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2618           *-*-freebsd2*|*-*-freebsd3.0*)
2619             case "$compile_command " in
2620             *" -static "*) ;;
2621             *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
2622             esac
2623           esac
2624
2625           # Now compile the dynamic symbol file.
2626           $show "(cd $output_objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
2627           $run eval '(cd $output_objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
2628
2629           # Clean up the generated files.
2630           $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
2631           $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
2632
2633           # Transform the symbol file into the correct name.
2634           compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
2635           finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
2636           ;;
2637         *)
2638           $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
2639           exit 1
2640           ;;
2641         esac
2642       else
2643         # We keep going just in case the user didn't refer to
2644         # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2645         # really was required.
2646
2647         # Nullify the symbol file.
2648         compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2649         finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2650       fi
2651
2652       if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then
2653         # Replace the output file specification.
2654         compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
2655         link_command="$compile_command$compile_rpath"
2656
2657         # We have no uninstalled library dependencies, so finalize right now.
2658         $show "$link_command"
2659         $run eval "$link_command"
2660         status=$?
2661         
2662         # Delete the generated files.
2663         if test -n "$dlsyms"; then
2664           $show "$rm $output_objdir/${outputname}S.${objext}"
2665           $run $rm "$output_objdir/${outputname}S.${objext}"
2666         fi
2667
2668         exit $status
2669       fi
2670
2671       if test -n "$shlibpath_var"; then
2672         # We should set the shlibpath_var
2673         rpath=
2674         for dir in $temp_rpath; do
2675           case "$dir" in
2676           [\\/]* | [A-Za-z]:[\\/]*)
2677             # Absolute path.
2678             rpath="$rpath$dir:"
2679             ;;
2680           *)
2681             # Relative path: add a thisdir entry.
2682             rpath="$rpath\$thisdir/$dir:"
2683             ;;
2684           esac
2685         done
2686         temp_rpath="$rpath"
2687       fi
2688
2689       if test -n "$compile_shlibpath$finalize_shlibpath"; then
2690         compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
2691       fi
2692       if test -n "$finalize_shlibpath"; then
2693         finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
2694       fi
2695
2696       compile_var=
2697       finalize_var=
2698       if test -n "$runpath_var"; then
2699         if test -n "$perm_rpath"; then
2700           # We should set the runpath_var.
2701           rpath=
2702           for dir in $perm_rpath; do
2703             rpath="$rpath$dir:"
2704           done
2705           compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
2706         fi
2707         if test -n "$finalize_perm_rpath"; then
2708           # We should set the runpath_var.
2709           rpath=
2710           for dir in $finalize_perm_rpath; do
2711             rpath="$rpath$dir:"
2712           done
2713           finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
2714         fi
2715       fi
2716
2717       if test "$hardcode_action" = relink; then
2718         # Fast installation is not supported
2719         link_command="$compile_var$compile_command$compile_rpath"
2720         relink_command="$finalize_var$finalize_command$finalize_rpath"
2721         
2722         $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
2723         $echo "$modename: \`$output' will be relinked during installation" 1>&2
2724       else
2725         if test "$fast_install" != no; then
2726           link_command="$finalize_var$compile_command$finalize_rpath"
2727           if test "$fast_install" = yes; then
2728             relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
2729           else
2730             # fast_install is set to needless
2731             relink_command=
2732           fi
2733         else
2734           link_command="$compile_var$compile_command$compile_rpath"
2735           relink_command="$finalize_var$finalize_command$finalize_rpath"
2736         fi
2737       fi
2738
2739       # Replace the output file specification.
2740       link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
2741       
2742       # Delete the old output files.
2743       $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
2744
2745       $show "$link_command"
2746       $run eval "$link_command" || exit $?
2747
2748       # Now create the wrapper script.
2749       $show "creating $output"
2750
2751       # Quote the relink command for shipping.
2752       if test -n "$relink_command"; then
2753         relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
2754       fi
2755
2756       # Quote $echo for shipping.
2757       if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
2758         case "$0" in
2759         [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
2760         *) qecho="$SHELL `pwd`/$0 --fallback-echo";;
2761         esac
2762         qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
2763       else
2764         qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
2765       fi
2766
2767       # Only actually do things if our run command is non-null.
2768       if test -z "$run"; then
2769         # win32 will think the script is a binary if it has
2770         # a .exe suffix, so we strip it off here.
2771         case $output in
2772           *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
2773         esac
2774         $rm $output
2775         trap "$rm $output; exit 1" 1 2 15
2776
2777         $echo > $output "\
2778 #! $SHELL
2779
2780 # $output - temporary wrapper script for $objdir/$outputname
2781 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
2782 #
2783 # The $output program cannot be directly executed until all the libtool
2784 # libraries that it depends on are installed.
2785 #
2786 # This wrapper script should never be moved out of the build directory.
2787 # If it is, it will not operate correctly.
2788
2789 # Sed substitution that helps us do robust quoting.  It backslashifies
2790 # metacharacters that are still active within double-quoted strings.
2791 Xsed='sed -e 1s/^X//'
2792 sed_quote_subst='$sed_quote_subst'
2793
2794 # The HP-UX ksh and POSIX shell print the target directory to stdout
2795 # if CDPATH is set.
2796 if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi
2797
2798 relink_command=\"$relink_command\"
2799
2800 # This environment variable determines our operation mode.
2801 if test \"\$libtool_install_magic\" = \"$magic\"; then
2802   # install mode needs the following variable:
2803   link_against_libtool_libs='$link_against_libtool_libs'
2804 else
2805   # When we are sourced in execute mode, \$file and \$echo are already set.
2806   if test \"\$libtool_execute_magic\" != \"$magic\"; then
2807     echo=\"$qecho\"
2808     file=\"\$0\"
2809     # Make sure echo works.
2810     if test \"X\$1\" = X--no-reexec; then
2811       # Discard the --no-reexec flag, and continue.
2812       shift
2813     elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
2814       # Yippee, \$echo works!
2815       :
2816     else
2817       # Restart under the correct shell, and then maybe \$echo will work.
2818       exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2819     fi
2820   fi\
2821 "
2822         $echo >> $output "\
2823
2824   # Find the directory that this script lives in.
2825   thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2826   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2827
2828   # Follow symbolic links until we get to the real thisdir.
2829   file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
2830   while test -n \"\$file\"; do
2831     destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2832
2833     # If there was a directory component, then change thisdir.
2834     if test \"x\$destdir\" != \"x\$file\"; then
2835       case \"\$destdir\" in
2836       [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;;
2837       *) thisdir=\"\$thisdir/\$destdir\" ;;
2838       esac
2839     fi
2840
2841     file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2842     file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
2843   done
2844
2845   # Try to get the absolute directory name.
2846   absdir=\`cd \"\$thisdir\" && pwd\`
2847   test -n \"\$absdir\" && thisdir=\"\$absdir\"
2848 "
2849
2850         if test "$fast_install" = yes; then
2851           echo >> $output "\
2852   program=lt-'$outputname'
2853   progdir=\"\$thisdir/$objdir\"
2854   
2855   if test ! -f \"\$progdir/\$program\" || \\
2856      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
2857        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2858
2859     file=\"\$\$-\$program\"
2860
2861     if test ! -d \"\$progdir\"; then
2862       $mkdir \"\$progdir\"
2863     else
2864       $rm \"\$progdir/\$file\"
2865     fi"
2866
2867           echo >> $output "\
2868
2869     # relink executable if necessary
2870     if test -n \"\$relink_command\"; then
2871       if (cd \"\$thisdir\" && eval \$relink_command); then :
2872       else
2873         $rm \"\$progdir/\$file\"
2874         exit 1
2875       fi
2876     fi
2877
2878     $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2879     { $rm \"\$progdir/\$program\";
2880       $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2881     $rm \"\$progdir/\$file\"
2882   fi"
2883         else
2884           echo >> $output "\
2885   program='$outputname$exeext'
2886   progdir=\"\$thisdir/$objdir\"
2887 "
2888         fi
2889
2890         echo >> $output "\
2891
2892   if test -f \"\$progdir/\$program\"; then"
2893
2894         # Export our shlibpath_var if we have one.
2895         if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2896           $echo >> $output "\
2897     # Add our own library path to $shlibpath_var
2898     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2899
2900     # Some systems cannot cope with colon-terminated $shlibpath_var
2901     # The second colon is a workaround for a bug in BeOS R4 sed
2902     $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2903
2904     export $shlibpath_var
2905 "
2906         fi
2907
2908         # fixup the dll searchpath if we need to.
2909         if test -n "$dllsearchpath"; then
2910           $echo >> $output "\
2911     # Add the dll search path components to the executable PATH
2912     PATH=$dllsearchpath:\$PATH
2913 "
2914         fi
2915
2916         $echo >> $output "\
2917     if test \"\$libtool_execute_magic\" != \"$magic\"; then
2918       # Run the actual program with our arguments.
2919 "
2920         case $host in
2921         *-*-cygwin* | *-*-mingw | *-*-os2*)
2922           # win32 systems need to use the prog path for dll
2923           # lookup to work
2924           $echo >> $output "\
2925       exec \$progdir\\\\\$program \${1+\"\$@\"}
2926 "
2927           ;;
2928         *)
2929           $echo >> $output "\
2930       # Export the path to the program.
2931       PATH=\"\$progdir:\$PATH\"
2932       export PATH
2933
2934       exec \$program \${1+\"\$@\"}
2935 "
2936           ;;
2937         esac
2938         $echo >> $output "\
2939       \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
2940       exit 1
2941     fi
2942   else
2943     # The program doesn't exist.
2944     \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
2945     \$echo \"This script is just a wrapper for \$program.\" 1>&2
2946     echo \"See the $PACKAGE documentation for more information.\" 1>&2
2947     exit 1
2948   fi
2949 fi\
2950 "
2951         chmod +x $output
2952       fi
2953       exit 0
2954       ;;
2955     esac
2956
2957     # See if we need to build an old-fashioned archive.
2958     for oldlib in $oldlibs; do
2959
2960       if test "$build_libtool_libs" = convenience; then
2961         oldobjs="$libobjs_save"
2962         addlibs="$convenience"
2963         build_libtool_libs=no
2964       else
2965         if test "$build_libtool_libs" = module; then
2966           oldobjs="$libobjs_save"
2967           build_libtool_libs=no
2968         else
2969           oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
2970         fi
2971         addlibs="$old_convenience"
2972       fi
2973
2974       if test -n "$addlibs"; then
2975         gentop="$output_objdir/${outputname}x"
2976         $show "${rm}r $gentop"
2977         $run ${rm}r "$gentop"
2978         $show "mkdir $gentop"
2979         $run mkdir "$gentop"
2980         status=$?
2981         if test $status -ne 0 && test ! -d "$gentop"; then
2982           exit $status
2983         fi
2984         generated="$generated $gentop"
2985           
2986         # Add in members from convenience archives.
2987         for xlib in $addlibs; do
2988           # Extract the objects.
2989           case "$xlib" in
2990           [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
2991           *) xabs=`pwd`"/$xlib" ;;
2992           esac
2993           xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
2994           xdir="$gentop/$xlib"
2995
2996           $show "${rm}r $xdir"
2997           $run ${rm}r "$xdir"
2998           $show "mkdir $xdir"
2999           $run mkdir "$xdir"
3000           status=$?
3001           if test $status -ne 0 && test ! -d "$xdir"; then
3002             exit $status
3003           fi
3004           $show "(cd $xdir && $AR x $xabs)"
3005           $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3006
3007           oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
3008         done
3009       fi
3010
3011       # Do each command in the archive commands.
3012       if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
3013         eval cmds=\"$old_archive_from_new_cmds\"
3014       else
3015         # Ensure that we have .o objects in place incase we decided
3016         # not to build a shared library, and have fallen back to building
3017         # static libs even though --disable-static was passed!
3018         for oldobj in $oldobjs; do
3019           if test ! -f $oldobj; then
3020             obj=`$echo "X$oldobj" | $Xsed -e "$o2lo"`
3021             $show "${LN_S} $obj $oldobj"
3022             $run ${LN_S} $obj $oldobj || exit $?
3023           fi
3024         done
3025
3026         eval cmds=\"$old_archive_cmds\"
3027       fi
3028       IFS="${IFS=       }"; save_ifs="$IFS"; IFS='~'
3029       for cmd in $cmds; do
3030         IFS="$save_ifs"
3031         $show "$cmd"
3032         $run eval "$cmd" || exit $?
3033       done
3034       IFS="$save_ifs"
3035     done
3036
3037     if test -n "$generated"; then
3038       $show "${rm}r$generated"
3039       $run ${rm}r$generated
3040     fi
3041
3042     # Now create the libtool archive.
3043     case "$output" in
3044     *.la)
3045       old_library=
3046       test "$build_old_libs" = yes && old_library="$libname.$libext"
3047       $show "creating $output"
3048
3049       if test -n "$xrpath"; then
3050         temp_xrpath=
3051         for libdir in $xrpath; do
3052           temp_xrpath="$temp_xrpath -R$libdir"
3053         done
3054         dependency_libs="$temp_xrpath $dependency_libs"
3055       fi
3056
3057       # Only create the output if not a dry run.
3058       if test -z "$run"; then
3059         for installed in no yes; do
3060           if test "$installed" = yes; then
3061             if test -z "$install_libdir"; then
3062               break
3063             fi
3064             output="$output_objdir/$outputname"i
3065           fi
3066           $rm $output
3067           $echo > $output "\
3068 # $outputname - a libtool library file
3069 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
3070 #
3071 # Please DO NOT delete this file!
3072 # It is necessary for linking the library.
3073
3074 # The name that we can dlopen(3).
3075 dlname='$dlname'
3076
3077 # Names of this library.
3078 library_names='$library_names'
3079
3080 # The name of the static archive.
3081 old_library='$old_library'
3082
3083 # Libraries that this one depends upon.
3084 dependency_libs='$dependency_libs'
3085
3086 # Version information for $libname.
3087 current=$current
3088 age=$age
3089 revision=$revision
3090
3091 # Is this an already installed library?
3092 installed=$installed
3093
3094 # Directory that this library needs to be installed in:
3095 libdir='$install_libdir'\
3096 "
3097         done
3098       fi
3099
3100       # Do a symbolic link so that the libtool archive can be found in
3101       # LD_LIBRARY_PATH before the program is installed.
3102       $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
3103       $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $?
3104       ;;
3105     esac
3106     exit 0
3107     ;;
3108
3109   # libtool install mode
3110   install)
3111     modename="$modename: install"
3112
3113     # There may be an optional sh(1) argument at the beginning of
3114     # install_prog (especially on Windows NT).
3115     if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then
3116       # Aesthetically quote it.
3117       arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
3118       case "$arg" in
3119       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*)
3120         arg="\"$arg\""
3121         ;;
3122       esac
3123       install_prog="$arg "
3124       arg="$1"
3125       shift
3126     else
3127       install_prog=
3128       arg="$nonopt"
3129     fi
3130
3131     # The real first argument should be the name of the installation program.
3132     # Aesthetically quote it.
3133     arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
3134     case "$arg" in
3135     *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*)
3136       arg="\"$arg\""
3137       ;;
3138     esac
3139     install_prog="$install_prog$arg"
3140
3141     # We need to accept at least all the BSD install flags.
3142     dest=
3143     files=
3144     opts=
3145     prev=
3146     install_type=
3147     isdir=no
3148     stripme=
3149     for arg
3150     do
3151       if test -n "$dest"; then
3152         files="$files $dest"
3153         dest="$arg"
3154         continue
3155       fi
3156
3157       case "$arg" in
3158       -d) isdir=yes ;;
3159       -f) prev="-f" ;;
3160       -g) prev="-g" ;;
3161       -m) prev="-m" ;;
3162       -o) prev="-o" ;;
3163       -s)
3164         stripme=" -s"
3165         continue
3166         ;;
3167       -*) ;;
3168
3169       *)
3170         # If the previous option needed an argument, then skip it.
3171         if test -n "$prev"; then
3172           prev=
3173         else
3174           dest="$arg"
3175           continue
3176         fi
3177         ;;
3178       esac
3179
3180       # Aesthetically quote the argument.
3181       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
3182       case "$arg" in
3183       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*)
3184         arg="\"$arg\""
3185         ;;
3186       esac
3187       install_prog="$install_prog $arg"
3188     done
3189
3190     if test -z "$install_prog"; then
3191       $echo "$modename: you must specify an install program" 1>&2
3192       $echo "$help" 1>&2
3193       exit 1
3194     fi
3195
3196     if test -n "$prev"; then
3197       $echo "$modename: the \`$prev' option requires an argument" 1>&2
3198       $echo "$help" 1>&2
3199       exit 1
3200     fi
3201
3202     if test -z "$files"; then
3203       if test -z "$dest"; then
3204         $echo "$modename: no file or destination specified" 1>&2
3205       else
3206         $echo "$modename: you must specify a destination" 1>&2
3207       fi
3208       $echo "$help" 1>&2
3209       exit 1
3210     fi
3211
3212     # Strip any trailing slash from the destination.
3213     dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
3214
3215     # Check to see that the destination is a directory.
3216     test -d "$dest" && isdir=yes
3217     if test "$isdir" = yes; then
3218       destdir="$dest"
3219       destname=
3220     else
3221       destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
3222       test "X$destdir" = "X$dest" && destdir=.
3223       destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
3224
3225       # Not a directory, so check to see that there is only one file specified.
3226       set dummy $files
3227       if test $# -gt 2; then
3228         $echo "$modename: \`$dest' is not a directory" 1>&2
3229         $echo "$help" 1>&2
3230         exit 1
3231       fi
3232     fi
3233     case "$destdir" in
3234     [\\/]* | [A-Za-z]:[\\/]*) ;;
3235     *)
3236       for file in $files; do
3237         case "$file" in
3238         *.lo) ;;
3239         *)
3240           $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
3241           $echo "$help" 1>&2
3242           exit 1
3243           ;;
3244         esac
3245       done
3246       ;;
3247     esac
3248
3249     # This variable tells wrapper scripts just to set variables rather
3250     # than running their programs.
3251     libtool_install_magic="$magic"
3252
3253     staticlibs=
3254     future_libdirs=
3255     current_libdirs=
3256     for file in $files; do
3257
3258       # Do each installation.
3259       case "$file" in
3260       *.a | *.lib)
3261         # Do the static libraries later.
3262         staticlibs="$staticlibs $file"
3263         ;;
3264
3265       *.la)
3266         # Check to see that this really is a libtool archive.
3267         if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
3268         else
3269           $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
3270           $echo "$help" 1>&2
3271           exit 1
3272         fi
3273
3274         library_names=
3275         old_library=
3276         # If there is no directory component, then add one.
3277         case "$file" in
3278         */* | *\\*) . $file ;;
3279         *) . ./$file ;;
3280         esac
3281
3282         # Add the libdir to current_libdirs if it is the destination.
3283         if test "X$destdir" = "X$libdir"; then
3284           case "$current_libdirs " in
3285           *" $libdir "*) ;;
3286           *) current_libdirs="$current_libdirs $libdir" ;;
3287           esac
3288         else
3289           # Note the libdir as a future libdir.
3290           case "$future_libdirs " in
3291           *" $libdir "*) ;;
3292           *) future_libdirs="$future_libdirs $libdir" ;;
3293           esac
3294         fi
3295
3296         dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/"
3297         test "X$dir" = "X$file/" && dir=
3298         dir="$dir$objdir"
3299
3300         # See the names of the shared library.
3301         set dummy $library_names
3302         if test -n "$2"; then
3303           realname="$2"
3304           shift
3305           shift
3306
3307           # Install the shared library and build the symlinks.
3308           $show "$install_prog $dir/$realname $destdir/$realname"
3309           $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $?
3310
3311           if test $# -gt 0; then
3312             # Delete the old symlinks, and create new ones.
3313             for linkname
3314             do
3315               if test "$linkname" != "$realname"; then
3316                 $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
3317                 $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
3318               fi
3319             done
3320           fi
3321
3322           # Do each command in the postinstall commands.
3323           lib="$destdir/$realname"
3324           eval cmds=\"$postinstall_cmds\"
3325           IFS="${IFS=   }"; save_ifs="$IFS"; IFS='~'
3326           for cmd in $cmds; do
3327             IFS="$save_ifs"
3328             $show "$cmd"
3329             $run eval "$cmd" || exit $?
3330           done
3331           IFS="$save_ifs"
3332         fi
3333
3334         # Install the pseudo-library for information purposes.
3335         name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
3336         instname="$dir/$name"i
3337         $show "$install_prog $instname $destdir/$name"
3338         $run eval "$install_prog $instname $destdir/$name" || exit $?
3339
3340         # Maybe install the static library, too.
3341         test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
3342         ;;
3343
3344       *.lo)
3345         # Install (i.e. copy) a libtool object.
3346
3347         # Figure out destination file name, if it wasn't already specified.
3348         if test -n "$destname"; then
3349           destfile="$destdir/$destname"
3350         else
3351           destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
3352           destfile="$destdir/$destfile"
3353         fi
3354
3355         # Deduce the name of the destination old-style object file.
3356         case "$destfile" in
3357         *.lo)
3358           staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
3359           ;;
3360         *.o | *.obj)
3361           staticdest="$destfile"
3362           destfile=
3363           ;;
3364         *)
3365           $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
3366           $echo "$help" 1>&2
3367           exit 1
3368           ;;
3369         esac
3370
3371         # Install the libtool object if requested.
3372         if test -n "$destfile"; then
3373           $show "$install_prog $file $destfile"
3374           $run eval "$install_prog $file $destfile" || exit $?
3375         fi
3376
3377         # Install the old object if enabled.
3378         if test "$build_old_libs" = yes; then
3379           # Deduce the name of the old-style object file.
3380           staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
3381
3382           $show "$install_prog $staticobj $staticdest"
3383           $run eval "$install_prog \$staticobj \$staticdest" || exit $?
3384         fi
3385         exit 0
3386         ;;
3387
3388       *)
3389         # Figure out destination file name, if it wasn't already specified.
3390         if test -n "$destname"; then
3391           destfile="$destdir/$destname"
3392         else
3393           destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
3394           destfile="$destdir/$destfile"
3395         fi
3396
3397         # Do a test to see if this is really a libtool program.
3398         if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
3399           link_against_libtool_libs=
3400           relink_command=
3401
3402           # If there is no directory component, then add one.
3403           case "$file" in
3404           */* | *\\*) . $file ;;
3405           *) . ./$file ;;
3406           esac
3407
3408           # Check the variables that should have been set.
3409           if test -z "$link_against_libtool_libs"; then
3410             $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
3411             exit 1
3412           fi
3413
3414           finalize=yes
3415           for lib in $link_against_libtool_libs; do
3416             # Check to see that each library is installed.
3417             libdir=
3418             if test -f "$lib"; then
3419               # If there is no directory component, then add one.
3420               case "$lib" in
3421               */* | *\\*) . $lib ;;
3422               *) . ./$lib ;;
3423               esac
3424             fi
3425             libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`"
3426             if test -n "$libdir" && test ! -f "$libfile"; then
3427               $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
3428               finalize=no
3429             fi
3430           done
3431
3432           outputname=
3433           if test "$fast_install" = no && test -n "$relink_command"; then
3434             if test "$finalize" = yes && test -z "$run"; then
3435               tmpdir="/tmp"
3436               test -n "$TMPDIR" && tmpdir="$TMPDIR"
3437               tmpdir="$tmpdir/libtool-$$"
3438               if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
3439               else
3440                 $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
3441                 continue
3442               fi
3443               outputname="$tmpdir/$file"
3444               # Replace the output file specification.
3445               relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
3446
3447               $show "$relink_command"
3448               if $run eval "$relink_command"; then :
3449               else
3450                 $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
3451                 ${rm}r "$tmpdir"
3452                 continue
3453               fi
3454               file="$outputname"
3455             else
3456               $echo "$modename: warning: cannot relink \`$file'" 1>&2
3457             fi
3458           else
3459             # Install the binary that we compiled earlier.
3460             file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
3461           fi
3462         fi
3463
3464         $show "$install_prog$stripme $file $destfile"
3465         $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
3466         test -n "$outputname" && ${rm}r "$tmpdir"
3467         ;;
3468       esac
3469     done
3470
3471     for file in $staticlibs; do
3472       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
3473
3474       # Set up the ranlib parameters.
3475       oldlib="$destdir/$name"
3476
3477       $show "$install_prog $file $oldlib"
3478       $run eval "$install_prog \$file \$oldlib" || exit $?
3479
3480       # Do each command in the postinstall commands.
3481       eval cmds=\"$old_postinstall_cmds\"
3482       IFS="${IFS=       }"; save_ifs="$IFS"; IFS='~'
3483       for cmd in $cmds; do
3484         IFS="$save_ifs"
3485         $show "$cmd"
3486         $run eval "$cmd" || exit $?
3487       done
3488       IFS="$save_ifs"
3489     done
3490
3491     if test -n "$future_libdirs"; then
3492       $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
3493     fi
3494
3495     if test -n "$current_libdirs"; then
3496       # Maybe just do a dry run.
3497       test -n "$run" && current_libdirs=" -n$current_libdirs"
3498       exec $SHELL $0 --finish$current_libdirs
3499       exit 1
3500     fi
3501
3502     exit 0
3503     ;;
3504
3505   # libtool finish mode
3506   finish)
3507     modename="$modename: finish"
3508     libdirs="$nonopt"
3509     admincmds=
3510
3511     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
3512       for dir
3513       do
3514         libdirs="$libdirs $dir"
3515       done
3516
3517       for libdir in $libdirs; do
3518         if test -n "$finish_cmds"; then
3519           # Do each command in the finish commands.
3520           eval cmds=\"$finish_cmds\"
3521           IFS="${IFS=   }"; save_ifs="$IFS"; IFS='~'
3522           for cmd in $cmds; do
3523             IFS="$save_ifs"
3524             $show "$cmd"
3525             $run eval "$cmd" || admincmds="$admincmds
3526        $cmd"
3527           done
3528           IFS="$save_ifs"
3529         fi
3530         if test -n "$finish_eval"; then
3531           # Do the single finish_eval.
3532           eval cmds=\"$finish_eval\"
3533           $run eval "$cmds" || admincmds="$admincmds
3534        $cmds"
3535         fi
3536       done
3537     fi
3538
3539     # Exit here if they wanted silent mode.
3540     test "$show" = : && exit 0
3541
3542     echo "----------------------------------------------------------------------"
3543     echo "Libraries have been installed in:"
3544     for libdir in $libdirs; do
3545       echo "   $libdir"
3546     done
3547     echo
3548     echo "If you ever happen to want to link against installed libraries"
3549     echo "in a given directory, LIBDIR, you must either use libtool, and"
3550     echo "specify the full pathname of the library, or use \`-LLIBDIR'"
3551     echo "flag during linking and do at least one of the following:"
3552     if test -n "$shlibpath_var"; then
3553       echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
3554       echo "     during execution"
3555     fi
3556     if test -n "$runpath_var"; then
3557       echo "   - add LIBDIR to the \`$runpath_var' environment variable"
3558       echo "     during linking"
3559     fi
3560     if test -n "$hardcode_libdir_flag_spec"; then
3561       libdir=LIBDIR
3562       eval flag=\"$hardcode_libdir_flag_spec\"
3563
3564       echo "   - use the \`$flag' linker flag"
3565     fi
3566     if test -n "$admincmds"; then
3567       echo "   - have your system administrator run these commands:$admincmds"
3568     fi
3569     if test -f /etc/ld.so.conf; then
3570       echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
3571     fi
3572     echo
3573     echo "See any operating system documentation about shared libraries for"
3574     echo "more information, such as the ld(1) and ld.so(8) manual pages."
3575     echo "----------------------------------------------------------------------"
3576     exit 0
3577     ;;
3578
3579   # libtool execute mode
3580   execute)
3581     modename="$modename: execute"
3582
3583     # The first argument is the command name.
3584     cmd="$nonopt"
3585     if test -z "$cmd"; then
3586       $echo "$modename: you must specify a COMMAND" 1>&2
3587       $echo "$help"
3588       exit 1
3589     fi
3590
3591     # Handle -dlopen flags immediately.
3592     for file in $execute_dlfiles; do
3593       if test ! -f "$file"; then
3594         $echo "$modename: \`$file' is not a file" 1>&2
3595         $echo "$help" 1>&2
3596         exit 1
3597       fi
3598
3599       dir=
3600       case "$file" in
3601       *.la)
3602         # Check to see that this really is a libtool archive.
3603         if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
3604         else
3605           $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
3606           $echo "$help" 1>&2
3607           exit 1
3608         fi
3609
3610         # Read the libtool library.
3611         dlname=
3612         library_names=
3613
3614         # If there is no directory component, then add one.
3615         case "$file" in
3616         */* | *\\*) . $file ;;
3617         *) . ./$file ;;
3618         esac
3619
3620         # Skip this library if it cannot be dlopened.
3621         if test -z "$dlname"; then
3622           # Warn if it was a shared library.
3623           test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
3624           continue
3625         fi
3626
3627         dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
3628         test "X$dir" = "X$file" && dir=.
3629
3630         if test -f "$dir/$objdir/$dlname"; then
3631           dir="$dir/$objdir"
3632         else
3633           $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
3634           exit 1
3635         fi
3636         ;;
3637
3638       *.lo)
3639         # Just add the directory containing the .lo file.
3640         dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
3641         test "X$dir" = "X$file" && dir=.
3642         ;;
3643
3644       *)
3645         $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
3646         continue
3647         ;;
3648       esac
3649
3650       # Get the absolute pathname.
3651       absdir=`cd "$dir" && pwd`
3652       test -n "$absdir" && dir="$absdir"
3653
3654       # Now add the directory to shlibpath_var.
3655       if eval "test -z \"\$$shlibpath_var\""; then
3656         eval "$shlibpath_var=\"\$dir\""
3657       else
3658         eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3659       fi
3660     done
3661
3662     # This variable tells wrapper scripts just to set shlibpath_var
3663     # rather than running their programs.
3664     libtool_execute_magic="$magic"
3665
3666     # Check if any of the arguments is a wrapper script.
3667     args=
3668     for file
3669     do
3670       case "$file" in
3671       -*) ;;
3672       *)
3673         # Do a test to see if this is really a libtool program.
3674         if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
3675           # If there is no directory component, then add one.
3676           case "$file" in
3677           */* | *\\*) . $file ;;
3678           *) . ./$file ;;
3679           esac
3680
3681           # Transform arg to wrapped name.
3682           file="$progdir/$program"
3683         fi
3684         ;;
3685       esac
3686       # Quote arguments (to preserve shell metacharacters).
3687       file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
3688       args="$args \"$file\""
3689     done
3690
3691     if test -z "$run"; then
3692       # Export the shlibpath_var.
3693       eval "export $shlibpath_var"
3694
3695       # Restore saved enviroment variables
3696       if test "${save_LC_ALL+set}" = set; then
3697         LC_ALL="$save_LC_ALL"; export LC_ALL
3698       fi
3699       if test "${save_LANG+set}" = set; then
3700         LANG="$save_LANG"; export LANG
3701       fi
3702
3703       # Now actually exec the command.
3704       eval "exec \$cmd$args"
3705
3706       $echo "$modename: cannot exec \$cmd$args"
3707       exit 1
3708     else
3709       # Display what would be done.
3710       eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
3711       $echo "export $shlibpath_var"
3712       $echo "$cmd$args"
3713       exit 0
3714     fi
3715     ;;
3716
3717   # libtool uninstall mode
3718   uninstall)
3719     modename="$modename: uninstall"
3720     rm="$nonopt"
3721     files=
3722
3723     for arg
3724     do
3725       case "$arg" in
3726       -*) rm="$rm $arg" ;;
3727       *) files="$files $arg" ;;
3728       esac
3729     done
3730
3731     if test -z "$rm"; then
3732       $echo "$modename: you must specify an RM program" 1>&2
3733       $echo "$help" 1>&2
3734       exit 1
3735     fi
3736
3737     for file in $files; do
3738       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
3739       test "X$dir" = "X$file" && dir=.
3740       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
3741
3742       rmfiles="$file"
3743
3744       case "$name" in
3745       *.la)
3746         # Possibly a libtool archive, so verify it.
3747         if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
3748           . $dir/$name
3749
3750           # Delete the libtool libraries and symlinks.
3751           for n in $library_names; do
3752             rmfiles="$rmfiles $dir/$n"
3753           done
3754           test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library"
3755
3756           $show "$rm $rmfiles"
3757           $run $rm $rmfiles
3758
3759           if test -n "$library_names"; then
3760             # Do each command in the postuninstall commands.
3761             eval cmds=\"$postuninstall_cmds\"
3762             IFS="${IFS=         }"; save_ifs="$IFS"; IFS='~'
3763             for cmd in $cmds; do
3764               IFS="$save_ifs"
3765               $show "$cmd"
3766               $run eval "$cmd"
3767             done
3768             IFS="$save_ifs"
3769           fi
3770
3771           if test -n "$old_library"; then
3772             # Do each command in the old_postuninstall commands.
3773             eval cmds=\"$old_postuninstall_cmds\"
3774             IFS="${IFS=         }"; save_ifs="$IFS"; IFS='~'
3775             for cmd in $cmds; do
3776               IFS="$save_ifs"
3777               $show "$cmd"
3778               $run eval "$cmd"
3779             done
3780             IFS="$save_ifs"
3781           fi
3782
3783           # FIXME: should reinstall the best remaining shared library.
3784         fi
3785         ;;
3786
3787       *.lo)
3788         if test "$build_old_libs" = yes; then
3789           oldobj=`$echo "X$name" | $Xsed -e "$lo2o"`
3790           rmfiles="$rmfiles $dir/$oldobj"
3791         fi
3792         $show "$rm $rmfiles"
3793         $run $rm $rmfiles
3794         ;;
3795
3796       *)
3797         $show "$rm $rmfiles"
3798         $run $rm $rmfiles
3799         ;;
3800       esac
3801     done
3802     exit 0
3803     ;;
3804
3805   "")
3806     $echo "$modename: you must specify a MODE" 1>&2
3807     $echo "$generic_help" 1>&2
3808     exit 1
3809     ;;
3810   esac
3811
3812   $echo "$modename: invalid operation mode \`$mode'" 1>&2
3813   $echo "$generic_help" 1>&2
3814   exit 1
3815 fi # test -z "$show_help"
3816
3817 # We need to display help for each of the modes.
3818 case "$mode" in
3819 "") $echo \
3820 "Usage: $modename [OPTION]... [MODE-ARG]...
3821
3822 Provide generalized library-building support services.
3823
3824     --config          show all configuration variables
3825     --debug           enable verbose shell tracing
3826 -n, --dry-run         display commands without modifying any files
3827     --features        display basic configuration information and exit
3828     --finish          same as \`--mode=finish'
3829     --help            display this help message and exit
3830     --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
3831     --quiet           same as \`--silent'
3832     --silent          don't print informational messages
3833     --version         print version information
3834
3835 MODE must be one of the following:
3836
3837       compile         compile a source file into a libtool object
3838       execute         automatically set library path, then run a program
3839       finish          complete the installation of libtool libraries
3840       install         install libraries or executables
3841       link            create a library or an executable
3842       uninstall       remove libraries from an installed directory
3843
3844 MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
3845 a more detailed description of MODE."
3846   exit 0
3847   ;;
3848
3849 compile)
3850   $echo \
3851 "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3852
3853 Compile a source file into a libtool library object.
3854
3855 This mode accepts the following additional options:
3856
3857   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
3858   -static           always build a \`.o' file suitable for static linking
3859
3860 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
3861 from the given SOURCEFILE.
3862
3863 The output file name is determined by removing the directory component from
3864 SOURCEFILE, then substituting the C source code suffix \`.c' with the
3865 library object suffix, \`.lo'."
3866   ;;
3867
3868 execute)
3869   $echo \
3870 "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
3871
3872 Automatically set library path, then run a program.
3873
3874 This mode accepts the following additional options:
3875
3876   -dlopen FILE      add the directory containing FILE to the library path
3877
3878 This mode sets the library path environment variable according to \`-dlopen'
3879 flags.
3880
3881 If any of the ARGS are libtool executable wrappers, then they are translated
3882 into their corresponding uninstalled binary, and any of their required library
3883 directories are added to the library path.
3884
3885 Then, COMMAND is executed, with ARGS as arguments."
3886   ;;
3887
3888 finish)
3889   $echo \
3890 "Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
3891
3892 Complete the installation of libtool libraries.
3893
3894 Each LIBDIR is a directory that contains libtool libraries.
3895
3896 The commands that this mode executes may require superuser privileges.  Use
3897 the \`--dry-run' option if you just want to see what would be executed."
3898   ;;
3899
3900 install)
3901   $echo \
3902 "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
3903
3904 Install executables or libraries.
3905
3906 INSTALL-COMMAND is the installation command.  The first component should be
3907 either the \`install' or \`cp' program.
3908
3909 The rest of the components are interpreted as arguments to that command (only
3910 BSD-compatible install options are recognized)."
3911   ;;
3912
3913 link)
3914   $echo \
3915 "Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
3916
3917 Link object files or libraries together to form another library, or to
3918 create an executable program.
3919
3920 LINK-COMMAND is a command using the C compiler that you would use to create
3921 a program from several object files.
3922
3923 The following components of LINK-COMMAND are treated specially:
3924
3925   -all-static       do not do any dynamic linking at all
3926   -avoid-version    do not add a version suffix if possible
3927   -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
3928   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
3929   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3930   -export-symbols SYMFILE
3931                     try to export only the symbols listed in SYMFILE
3932   -export-symbols-regex REGEX
3933                     try to export only the symbols matching REGEX
3934   -LLIBDIR          search LIBDIR for required installed libraries
3935   -lNAME            OUTPUT-FILE requires the installed library libNAME
3936   -module           build a library that can dlopened
3937   -no-undefined     declare that a library does not refer to external symbols
3938   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
3939   -release RELEASE  specify package release information
3940   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
3941   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
3942   -static           do not do any dynamic linking of libtool libraries
3943   -version-info CURRENT[:REVISION[:AGE]]
3944                     specify library version info [each variable defaults to 0]
3945
3946 All other options (arguments beginning with \`-') are ignored.
3947
3948 Every other argument is treated as a filename.  Files ending in \`.la' are
3949 treated as uninstalled libtool libraries, other files are standard or library
3950 object files.
3951
3952 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
3953 only library objects (\`.lo' files) may be specified, and \`-rpath' is
3954 required, except when creating a convenience library.
3955
3956 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
3957 using \`ar' and \`ranlib', or on Windows using \`lib'.
3958
3959 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
3960 is created, otherwise an executable program is created."
3961   ;;
3962
3963 uninstall)
3964   $echo \
3965 "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3966
3967 Remove libraries from an installation directory.
3968
3969 RM is the name of the program to use to delete files associated with each FILE
3970 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
3971 to RM.
3972
3973 If FILE is a libtool library, all the files associated with it are deleted.
3974 Otherwise, only FILE itself is deleted using RM."
3975   ;;
3976
3977 *)
3978   $echo "$modename: invalid operation mode \`$mode'" 1>&2
3979   $echo "$help" 1>&2
3980   exit 1
3981   ;;
3982 esac
3983
3984 echo
3985 $echo "Try \`$modename --help' for more information about other modes."
3986
3987 exit 0
3988
3989 # Local Variables:
3990 # mode:shell-script
3991 # sh-indentation:2
3992 # End: