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