OSDN Git Service

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