#
[gcc.git] / 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-1998 Free Software Foundation, Inc.
5 # Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #
21 # As a special exception to the GNU General Public License, if you
22 # distribute this file as part of a program that contains a
23 # configuration script generated by Autoconf, you may include it under
24 # the same distribution terms that you use for the rest of that program.
25
26 # The name of this program.
27 progname=`$echo "$0" | sed 's%^.*/%%'`
28 modename="$progname"
29
30 # Constants.
31 PROGRAM=ltmain.sh
32 PACKAGE=libtool
33 VERSION=1.2a
34
35 default_mode=
36 help="Try \`$progname --help' for more information."
37 magic="%%%MAGIC variable%%%"
38 mkdir="mkdir"
39 mv="mv -f"
40 rm="rm -f"
41
42 # Sed substitution that helps us do robust quoting. It backslashifies
43 # metacharacters that are still active within double-quoted strings.
44 Xsed='sed -e s/^X//'
45 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
46
47 # NLS nuisances.
48 # Only set LANG and LC_ALL to C if already set.
49 # These must not be set unconditionally because not all systems understand
50 # e.g. LANG=C (notably SCO).
51 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
52 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
53
54 if test "$LTCONFIG_VERSION" != "$VERSION"; then
55 echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2
56 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
57 exit 1
58 fi
59
60 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
61 echo "$modename: not configured to build any kind of library" 1>&2
62 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
63 exit 1
64 fi
65
66 # Global variables.
67 mode=$default_mode
68 nonopt=
69 prev=
70 prevopt=
71 run=
72 show="$echo"
73 show_help=
74 execute_dlfiles=
75
76 # Parse our command line options once, thoroughly.
77 while test $# -gt 0
78 do
79 arg="$1"
80 shift
81
82 case "$arg" in
83 -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
84 *) optarg= ;;
85 esac
86
87 # If the previous option needs an argument, assign it.
88 if test -n "$prev"; then
89 case "$prev" in
90 execute_dlfiles)
91 eval "$prev=\"\$$prev \$arg\""
92 ;;
93 *)
94 eval "$prev=\$arg"
95 ;;
96 esac
97
98 prev=
99 prevopt=
100 continue
101 fi
102
103 # Have we seen a non-optional argument yet?
104 case "$arg" in
105 --help)
106 show_help=yes
107 ;;
108
109 --version)
110 echo "$PROGRAM (GNU $PACKAGE) $VERSION"
111 exit 0
112 ;;
113
114 --config)
115 sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0
116 exit 0
117 ;;
118
119 --debug)
120 echo "$progname: enabling shell trace mode"
121 set -x
122 ;;
123
124 --dry-run | -n)
125 run=:
126 ;;
127
128 --features)
129 echo "host: $host"
130 if test "$build_libtool_libs" = yes; then
131 echo "enable shared libraries"
132 else
133 echo "disable shared libraries"
134 fi
135 if test "$build_old_libs" = yes; then
136 echo "enable static libraries"
137 else
138 echo "disable static libraries"
139 fi
140 exit 0
141 ;;
142
143 --finish) mode="finish" ;;
144
145 --mode) prevopt="--mode" prev=mode ;;
146 --mode=*) mode="$optarg" ;;
147
148 --quiet | --silent)
149 show=:
150 ;;
151
152 -dlopen)
153 prevopt="-dlopen"
154 prev=execute_dlfiles
155 ;;
156
157 -*)
158 $echo "$modename: unrecognized option \`$arg'" 1>&2
159 $echo "$help" 1>&2
160 exit 1
161 ;;
162
163 *)
164 nonopt="$arg"
165 break
166 ;;
167 esac
168 done
169
170 if test -n "$prevopt"; then
171 $echo "$modename: option \`$prevopt' requires an argument" 1>&2
172 $echo "$help" 1>&2
173 exit 1
174 fi
175
176 if test -z "$show_help"; then
177
178 # Infer the operation mode.
179 if test -z "$mode"; then
180 case "$nonopt" in
181 *cc | *++ | gcc* | *-gcc*)
182 mode=link
183 for arg
184 do
185 case "$arg" in
186 -c)
187 mode=compile
188 break
189 ;;
190 esac
191 done
192 ;;
193 *db | *dbx)
194 mode=execute
195 ;;
196 *install*|cp|mv)
197 mode=install
198 ;;
199 *rm)
200 mode=uninstall
201 ;;
202 *)
203 # If we have no mode, but dlfiles were specified, then do execute mode.
204 test -n "$execute_dlfiles" && mode=execute
205
206 # Just use the default operation mode.
207 if test -z "$mode"; then
208 if test -n "$nonopt"; then
209 $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
210 else
211 $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
212 fi
213 fi
214 ;;
215 esac
216 fi
217
218 # Only execute mode is allowed to have -dlopen flags.
219 if test -n "$execute_dlfiles" && test "$mode" != execute; then
220 $echo "$modename: unrecognized option \`-dlopen'" 1>&2
221 $echo "$help" 1>&2
222 exit 1
223 fi
224
225 # Change the help message to a mode-specific one.
226 generic_help="$help"
227 help="Try \`$modename --help --mode=$mode' for more information."
228
229 # These modes are in order of execution frequency so that they run quickly.
230 case "$mode" in
231 # libtool compile mode
232 compile)
233 modename="$modename: compile"
234 # Get the compilation command and the source file.
235 base_compile=
236 lastarg=
237 srcfile="$nonopt"
238 suppress_output=
239
240 for arg
241 do
242 # Accept any command-line options.
243 case "$arg" in
244 -o)
245 $echo "$modename: you cannot specify the output filename with \`-o'" 1>&2
246 $echo "$help" 1>&2
247 exit 1
248 ;;
249
250 -static)
251 build_libtool_libs=no
252 build_old_libs=yes
253 continue
254 ;;
255 esac
256
257 # Accept the current argument as the source file.
258 lastarg="$srcfile"
259 srcfile="$arg"
260
261 # Aesthetically quote the previous argument.
262
263 # Backslashify any backslashes, double quotes, and dollar signs.
264 # These are the only characters that are still specially
265 # interpreted inside of double-quoted scrings.
266 lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
267
268 # Double-quote args containing other shell metacharacters.
269 # Many Bourne shells cannot handle close brackets correctly in scan
270 # sets, so we specify it separately.
271 case "$lastarg" in
272 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
273 lastarg="\"$lastarg\""
274 ;;
275 esac
276
277 # Add the previous argument to base_compile.
278 if test -z "$base_compile"; then
279 base_compile="$lastarg"
280 else
281 base_compile="$base_compile $lastarg"
282 fi
283 done
284
285 # Get the name of the library object.
286 libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
287
288 # Recognize several different file suffixes.
289 xform='[cCFSfms]'
290 case "$libobj" in
291 *.ada) xform=ada ;;
292 *.adb) xform=adb ;;
293 *.ads) xform=ads ;;
294 *.asm) xform=asm ;;
295 *.c++) xform=c++ ;;
296 *.cc) xform=cc ;;
297 *.cpp) xform=cpp ;;
298 *.cxx) xform=cxx ;;
299 *.f90) xform=f90 ;;
300 *.for) xform=for ;;
301 esac
302
303 libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
304
305 case "$libobj" in
306 *.lo) obj=`$echo "X$libobj" | $Xsed -e 's/\.lo$/.o/'` ;;
307 *)
308 $echo "$modename: cannot determine name of library object from \`$srcfile'" 1>&2
309 exit 1
310 ;;
311 esac
312
313 if test -z "$base_compile"; then
314 $echo "$modename: you must specify a compilation command" 1>&2
315 $echo "$help" 1>&2
316 exit 1
317 fi
318
319 # Delete any leftover library objects.
320 if test "$build_old_libs" = yes; then
321 $run $rm $obj $libobj
322 trap "$run $rm $obj $libobj; exit 1" 1 2 15
323 else
324 $run $rm $libobj
325 trap "$run $rm $libobj; exit 1" 1 2 15
326 fi
327
328 # Only build a PIC object if we are building libtool libraries.
329 if test "$build_libtool_libs" = yes; then
330 # Without this assignment, base_compile gets emptied.
331 fbsd_hideous_sh_bug=$base_compile
332
333 # All platforms use -DPIC, to notify preprocessed assembler code.
334 $show "$base_compile$pic_flag -DPIC $srcfile"
335 if $run eval "$base_compile\$pic_flag -DPIC \$srcfile"; then :
336 else
337 test -n "$obj" && $run $rm $obj
338 exit 1
339 fi
340
341 # If we have no pic_flag, then copy the object into place and finish.
342 if test -z "$pic_flag"; then
343 $show "$LN_S $obj $libobj"
344 $run $LN_S $obj $libobj
345 exit $?
346 fi
347
348 # Just move the object, then go on to compile the next one
349 $show "$mv $obj $libobj"
350 $run $mv $obj $libobj || exit 1
351
352 # Allow error messages only from the first compilation.
353 suppress_output=' >/dev/null 2>&1'
354 fi
355
356 # Only build a position-dependent object if we build old libraries.
357 if test "$build_old_libs" = yes; then
358 # Suppress compiler output if we already did a PIC compilation.
359 $show "$base_compile $srcfile$suppress_output"
360 if $run eval "$base_compile \$srcfile$suppress_output"; then :
361 else
362 $run $rm $obj $libobj
363 exit 1
364 fi
365 fi
366
367 # Create an invalid libtool object if no PIC, so that we do not
368 # accidentally link it into a program.
369 if test "$build_libtool_libs" != yes; then
370 $show "echo timestamp > $libobj"
371 $run eval "echo timestamp > \$libobj" || exit $?
372 fi
373
374 exit 0
375 ;;
376
377 # libtool link mode
378 link)
379 modename="$modename: link"
380 CC="$nonopt"
381 allow_undefined=yes
382 compile_command="$CC"
383 finalize_command="$CC"
384
385 compile_shlibpath=
386 finalize_shlibpath=
387 deplibs=
388 dlfiles=
389 dlprefiles=
390 export_dynamic=no
391 hardcode_libdirs=
392 libobjs=
393 link_against_libtool_libs=
394 ltlibs=
395 objs=
396 prev=
397 prevarg=
398 release=
399 rpath=
400 perm_rpath=
401 temp_rpath=
402 vinfo=
403
404 # We need to know -static, to get the right output filenames.
405 for arg
406 do
407 case "$arg" in
408 -all-static | -static)
409 if test "X$arg" = "X-all-static" && test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
410 $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
411 fi
412 build_libtool_libs=no
413 build_old_libs=yes
414 break
415 ;;
416 esac
417 done
418
419 # See if our shared archives depend on static archives.
420 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
421
422 # Go through the arguments, transforming them on the way.
423 for arg
424 do
425 # If the previous option needs an argument, assign it.
426 if test -n "$prev"; then
427 case "$prev" in
428 output)
429 compile_command="$compile_command @OUTPUT@"
430 finalize_command="$finalize_command @OUTPUT@"
431 ;;
432 esac
433
434 case "$prev" in
435 dlfiles|dlprefiles)
436 case "$arg" in
437 *.la | *.lo) ;; # We handle these cases below.
438 *)
439 dlprefiles="$dlprefiles $arg"
440 test "$prev" = dlfiles && dlfiles="$dlfiles $arg"
441 prev=
442 ;;
443 esac
444 ;;
445 release)
446 release="-$arg"
447 prev=
448 continue
449 ;;
450 rpath)
451 rpath="$rpath $arg"
452 prev=
453 continue
454 ;;
455 *)
456 eval "$prev=\"\$arg\""
457 prev=
458 continue
459 ;;
460 esac
461 fi
462
463 prevarg="$arg"
464
465 case "$arg" in
466 -all-static)
467 if test -n "$link_static_flag"; then
468 compile_command="$compile_command $link_static_flag"
469 finalize_command="$finalize_command $link_static_flag"
470 fi
471 continue
472 ;;
473
474 -allow-undefined)
475 # FIXME: remove this flag sometime in the future.
476 $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
477 continue
478 ;;
479
480 -dlopen)
481 prev=dlfiles
482 continue
483 ;;
484
485 -dlpreopen)
486 prev=dlprefiles
487 continue
488 ;;
489
490 -export-dynamic)
491 if test "$export_dynamic" != yes; then
492 export_dynamic=yes
493 if test -n "$export_dynamic_flag_spec"; then
494 eval arg=\"$export_dynamic_flag_spec\"
495 else
496 arg=
497 fi
498
499 # Add the symbol object into the linking commands.
500 compile_command="$compile_command @SYMFILE@"
501 finalize_command="$finalize_command @SYMFILE@"
502 fi
503 ;;
504
505 -L*)
506 dir=`$echo "X$arg" | $Xsed -e 's%^-L\(.*\)$%\1%'`
507 case "$dir" in
508 /* | [A-Za-z]:\\*)
509 # Add the corresponding hardcode_libdir_flag, if it is not identical.
510 ;;
511 *)
512 $echo "$modename: \`-L$dir' cannot specify a relative directory" 1>&2
513 exit 1
514 ;;
515 esac
516 deplibs="$deplibs $arg"
517 ;;
518
519 -l*) deplibs="$deplibs $arg" ;;
520
521 -no-undefined)
522 allow_undefined=no
523 continue
524 ;;
525
526 -o) prev=output ;;
527
528 -release)
529 prev=release
530 continue
531 ;;
532
533 -rpath)
534 prev=rpath
535 continue
536 ;;
537
538 -static)
539 # If we have no pic_flag, then this is the same as -all-static.
540 if test -z "$pic_flag" && test -n "$link_static_flag"; then
541 compile_command="$compile_command $link_static_flag"
542 finalize_command="$finalize_command $link_static_flag"
543 fi
544 continue
545 ;;
546
547 -version-info)
548 prev=vinfo
549 continue
550 ;;
551
552 # Some other compiler flag.
553 -* | +*)
554 # Unknown arguments in both finalize_command and compile_command need
555 # to be aesthetically quoted because they are evaled later.
556 arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
557 case "$arg" in
558 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
559 arg="\"$arg\""
560 ;;
561 esac
562 ;;
563
564 *.o | *.a)
565 # A standard object.
566 objs="$objs $arg"
567 ;;
568
569 *.lo)
570 # A library object.
571 if test "$prev" = dlfiles; then
572 dlfiles="$dlfiles $arg"
573 if test "$build_libtool_libs" = yes; then
574 prev=
575 continue
576 else
577 # If libtool objects are unsupported, then we need to preload.
578 prev=dlprefiles
579 fi
580 fi
581
582 if test "$prev" = dlprefiles; then
583 # Preload the old-style object.
584 dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e 's/\.lo$/.o/'`
585 prev=
586 fi
587 libobjs="$libobjs $arg"
588 ;;
589
590 *.la)
591 # A libtool-controlled library.
592
593 dlname=
594 libdir=
595 library_names=
596 old_library=
597
598 # Check to see that this really is a libtool archive.
599 if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
600 else
601 $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
602 exit 1
603 fi
604
605 # If there is no directory component, then add one.
606 case "$arg" in
607 */* | *\\*) . $arg ;;
608 *) . ./$arg ;;
609 esac
610
611 if test -z "$libdir"; then
612 $echo "$modename: \`$arg' contains no -rpath information" 1>&2
613 exit 1
614 fi
615
616 # Get the name of the library we link against.
617 linklib=
618 for l in $old_library $library_names; do
619 linklib="$l"
620 done
621
622 if test -z "$linklib"; then
623 $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
624 exit 1
625 fi
626
627 # Find the relevant object directory and library name.
628 name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
629 dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
630 if test "X$dir" = "X$arg"; then
631 dir="$objdir"
632 else
633 dir="$dir/$objdir"
634 fi
635
636 # This library was specified with -dlopen.
637 if test "$prev" = dlfiles; then
638 dlfiles="$dlfiles $arg"
639 if test -z "$dlname"; then
640 # If there is no dlname, we need to preload.
641 prev=dlprefiles
642 else
643 # We should not create a dependency on this library, but we
644 # may need any libraries it requires.
645 compile_command="$compile_command$dependency_libs"
646 finalize_command="$finalize_command$dependency_libs"
647 prev=
648 continue
649 fi
650 fi
651
652 # The library was specified with -dlpreopen.
653 if test "$prev" = dlprefiles; then
654 # Prefer using a static library (so that no silly _DYNAMIC symbols
655 # are required to link).
656 if test -n "$old_library"; then
657 dlprefiles="$dlprefiles $dir/$old_library"
658 else
659 dlprefiles="$dlprefiles $dir/$linklib"
660 fi
661 prev=
662 fi
663
664 if test "$build_libtool_libs" = yes && test -n "$library_names"; then
665 link_against_libtool_libs="$link_against_libtool_libs $arg"
666 if test -n "$shlibpath_var"; then
667 # Make sure the rpath contains only unique directories.
668 case "$temp_rpath " in
669 *" $dir "*) ;;
670 *) temp_rpath="$temp_rpath $dir" ;;
671 esac
672 fi
673
674 # This is the magic to use -rpath.
675 if test -n "$hardcode_libdir_flag_spec"; then
676 if test -n "$hardcode_libdir_separator"; then
677 if test -z "$hardcode_libdirs"; then
678 # Put the magic libdir with the hardcode flag.
679 hardcode_libdirs="$libdir"
680 libdir="@HARDCODE_LIBDIRS@"
681 else
682 # Just accumulate the unique libdirs.
683 case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
684 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
685 ;;
686 *)
687 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
688 ;;
689 esac
690 libdir=
691 fi
692 fi
693
694 if test -n "$libdir"; then
695 eval flag=\"$hardcode_libdir_flag_spec\"
696
697 compile_command="$compile_command $flag"
698 finalize_command="$finalize_command $flag"
699 fi
700 elif test -n "$runpath_var"; then
701 # Do the same for the permanent run path.
702 case "$perm_rpath " in
703 *" $libdir "*) ;;
704 *) perm_rpath="$perm_rpath $libdir" ;;
705 esac
706 fi
707
708
709 case "$hardcode_action" in
710 immediate)
711 if test "$hardcode_direct" = no; then
712 compile_command="$compile_command $dir/$linklib"
713 elif test "$hardcode_minus_L" = no; then
714 compile_command="$compile_command -L$dir -l$name"
715 elif test "$hardcode_shlibpath_var" = no; then
716 compile_shlibpath="$compile_shlibpath$dir:"
717 compile_command="$compile_command -l$name"
718 fi
719 ;;
720
721 relink)
722 # We need an absolute path.
723 case "$dir" in
724 /* | [A-Za-z]:\\*) ;;
725 *)
726 absdir=`cd "$dir" && pwd`
727 if test -z "$absdir"; then
728 $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
729 exit 1
730 fi
731 dir="$absdir"
732 ;;
733 esac
734
735 if test "$hardcode_direct" = yes; then
736 compile_command="$compile_command $dir/$linklib"
737 elif test "$hardcode_minus_L" = yes; then
738 compile_command="$compile_command -L$dir -l$name"
739 elif test "$hardcode_shlibpath_var" = yes; then
740 compile_shlibpath="$compile_shlibpath$dir:"
741 compile_command="$compile_command -l$name"
742 fi
743 ;;
744 esac
745
746 # Finalize command for both is simple: just hardcode it.
747 if test "$hardcode_direct" = yes; then
748 finalize_command="$finalize_command $libdir/$linklib"
749 elif test "$hardcode_minus_L" = yes; then
750 finalize_command="$finalize_command -L$libdir -l$name"
751 elif test "$hardcode_shlibpath_var" = yes; then
752 finalize_shlibpath="$finalize_shlibpath$libdir:"
753 finalize_command="$finalize_command -l$name"
754 else
755 # We cannot seem to hardcode it, guess we'll fake it.
756 finalize_command="$finalize_command -L$libdir -l$name"
757 fi
758 else
759 # Transform directly to old archives if we don't build new libraries.
760 if test -n "$pic_flag" && test -z "$old_library"; then
761 $echo "$modename: cannot find static library for \`$arg'" 1>&2
762 exit 1
763 fi
764
765 # Here we assume that one of hardcode_direct or hardcode_minus_L
766 # is not unsupported. This is valid on all known static and
767 # shared platforms.
768 if test "$hardcode_direct" != unsupported; then
769 test -n "$old_library" && linklib="$old_library"
770 compile_command="$compile_command $dir/$linklib"
771 finalize_command="$finalize_command $dir/$linklib"
772 else
773 compile_command="$compile_command -L$dir -l$name"
774 finalize_command="$finalize_command -L$dir -l$name"
775 fi
776 fi
777
778 # Add in any libraries that this one depends upon.
779 compile_command="$compile_command$dependency_libs"
780 finalize_command="$finalize_command$dependency_libs"
781 continue
782 ;;
783
784 # Some other compiler argument.
785 *)
786 # Unknown arguments in both finalize_command and compile_command need
787 # to be aesthetically quoted because they are evaled later.
788 arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
789 case "$arg" in
790 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
791 arg="\"$arg\""
792 ;;
793 esac
794 ;;
795 esac
796
797 # Now actually substitute the argument into the commands.
798 if test -n "$arg"; then
799 compile_command="$compile_command $arg"
800 finalize_command="$finalize_command $arg"
801 fi
802 done
803
804 if test -n "$prev"; then
805 $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
806 $echo "$help" 1>&2
807 exit 1
808 fi
809
810 if test -n "$vinfo" && test -n "$release"; then
811 $echo "$modename: you cannot specify both \`-version-info' and \`-release'" 1>&2
812 $echo "$help" 1>&2
813 exit 1
814 fi
815
816 oldlib=
817 oldobjs=
818 case "$output" in
819 "")
820 $echo "$modename: you must specify an output file" 1>&2
821 $echo "$help" 1>&2
822 exit 1
823 ;;
824
825 */* | *\\*)
826 $echo "$modename: output file \`$output' must have no directory components" 1>&2
827 exit 1
828 ;;
829
830 *.a)
831 # Now set the variables for building old libraries.
832 build_libtool_libs=no
833 build_old_libs=yes
834 oldlib="$output"
835 $show "$rm $oldlib"
836 $run $rm $oldlib
837 ;;
838
839 *.la)
840 # Make sure we only generate libraries of the form `libNAME.la'.
841 case "$output" in
842 lib*) ;;
843 *)
844 $echo "$modename: libtool library \`$arg' must begin with \`lib'" 1>&2
845 $echo "$help" 1>&2
846 exit 1
847 ;;
848 esac
849
850 name=`$echo "X$output" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
851 eval libname=\"$libname_spec\"
852
853 # All the library-specific variables (install_libdir is set above).
854 library_names=
855 old_library=
856 dlname=
857 current=0
858 revision=0
859 age=0
860
861 if test -n "$objs"; then
862 $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
863 exit 1
864 fi
865
866 # How the heck are we supposed to write a wrapper for a shared library?
867 if test -n "$link_against_libtool_libs"; then
868 $echo "$modename: libtool library \`$output' may not depend on uninstalled libraries:$link_against_libtool_libs" 1>&2
869 exit 1
870 fi
871
872 if test -n "$dlfiles$dlprefiles"; then
873 $echo "$modename: warning: \`-dlopen' is ignored while creating libtool libraries" 1>&2
874 # Nullify the symbol file.
875 compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
876 finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
877 fi
878
879 if test -z "$rpath"; then
880 $echo "$modename: you must specify an installation directory with \`-rpath'" 1>&2
881 $echo "$help" 1>&2
882 exit 1
883 fi
884
885 set dummy $rpath
886 if test $# -gt 2; then
887 $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
888 fi
889 install_libdir="$2"
890
891 if test -n "$vinfo"; then
892
893 # Parse the version information argument.
894 IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
895 set dummy $vinfo
896 IFS="$save_ifs"
897
898 if test -n "$5"; then
899 $echo "$modename: too many parameters to \`-version-info'" 1>&2
900 $echo "$help" 1>&2
901 exit 1
902 fi
903
904 test -n "$2" && current="$2"
905 test -n "$3" && revision="$3"
906 test -n "$4" && age="$4"
907
908 # Check that each of the things are valid numbers.
909 case "$current" in
910 0 | [1-9] | [1-9][0-9]*) ;;
911 *)
912 $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
913 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
914 exit 1
915 ;;
916 esac
917
918 case "$revision" in
919 0 | [1-9] | [1-9][0-9]*) ;;
920 *)
921 $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
922 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
923 exit 1
924 ;;
925 esac
926
927 case "$age" in
928 0 | [1-9] | [1-9][0-9]*) ;;
929 *)
930 $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
931 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
932 exit 1
933 ;;
934 esac
935
936 if test $age -gt $current; then
937 $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
938 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
939 exit 1
940 fi
941
942 # Calculate the version variables.
943 version_vars="version_type current age revision"
944 case "$version_type" in
945 none) ;;
946
947 linux)
948 version_vars="$version_vars major versuffix"
949 major=.`expr $current - $age`
950 versuffix=".$major.$age.$revision"
951 ;;
952
953 osf)
954 version_vars="$version_vars versuffix verstring"
955 major=.`expr $current - $age`
956 versuffix=."$current.$age.$revision"
957 verstring="$current.$age.$revision"
958
959 # Add in all the interfaces that we are compatible with.
960 loop=$age
961 while test $loop != 0; do
962 iface=`expr $current - $loop`
963 loop=`expr $loop - 1`
964 verstring="$verstring:${iface}.0"
965 done
966
967 # Make executables depend on our current version.
968 verstring="$verstring:${current}.0"
969 ;;
970
971 sunos)
972 version_vars="$version_vars major versuffix"
973 major=."$current"
974 versuffix=."$current.$revision"
975 ;;
976
977 windows)
978 # Like Linux, but with '-' rather than '.', since we only
979 # want one extension on Windows 95.
980 version_vars="$version_vars major versuffix"
981 major=`expr $current - $age`
982 versuffix="-$major-$age-$revision"
983 ;;
984
985 *)
986 $echo "$modename: unknown library version type \`$version_type'" 1>&2
987 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
988 exit 1
989 ;;
990 esac
991 else
992
993 # No version information.
994 version_vars=
995
996 case "$version_type" in
997 none) ;;
998
999 linux)
1000 version_vars="$version_vars versuffix major"
1001 major=
1002 versuffix=
1003 ;;
1004
1005 osf)
1006 version_vars="$version_vars versuffix verstring"
1007 major=
1008 versuffix=
1009 verstring=":0.0"
1010 ;;
1011
1012 sunos)
1013 version_vars="$version_vars major versuffix"
1014 major=
1015 versuffix=
1016 ;;
1017
1018 windows)
1019 # Like Linux, but with '-' rather than '.', and with a leading
1020 # '-', since we only want one extension on Windows 95.
1021 version_vars="$version_vars major versuffix"
1022 major=
1023 versuffix=
1024 ;;
1025
1026 *)
1027 $echo "$modename: unknown library version type \`$version_type'" 1>&2
1028 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
1029 exit 1
1030 ;;
1031 esac
1032 fi
1033
1034 # Create the output directory, or remove our outputs if we need to.
1035 if test -d $objdir; then
1036 $show "$rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.*"
1037 $run $rm $objdir/$output $objdir/$libname.* $objdir/${libname}${release}.*
1038 else
1039 $show "$mkdir $objdir"
1040 $run $mkdir $objdir
1041 status=$?
1042 if test $status -eq 0 || test -d $objdir; then :
1043 else
1044 exit $status
1045 fi
1046 fi
1047
1048 # Check to see if the archive will have undefined symbols.
1049 if test "$allow_undefined" = yes; then
1050 if test "$allow_undefined_flag" = unsupported; then
1051 $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
1052 build_libtool_libs=no
1053 build_old_libs=yes
1054 fi
1055 else
1056 # Don't allow undefined symbols.
1057 allow_undefined_flag="$no_undefined_flag"
1058 fi
1059
1060 # Add libc to deplibs on all systems.
1061 dependency_libs="$deplibs"
1062 deplibs="$deplibs -lc"
1063
1064 if test "$build_libtool_libs" = yes; then
1065 # Get the real and link names of the library.
1066 eval library_names=\"$library_names_spec\"
1067 set dummy $library_names
1068 realname="$2"
1069 shift; shift
1070
1071 if test -n "$soname_spec"; then
1072 eval soname=\"$soname_spec\"
1073 else
1074 soname="$realname"
1075 fi
1076
1077 lib="$objdir/$realname"
1078 for link
1079 do
1080 linknames="$linknames $link"
1081 done
1082
1083 # Use standard objects if they are PIC.
1084 test -z "$pic_flag" && libobjs=`$echo "X$libobjs " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//g'`
1085
1086 # Do each of the archive commands.
1087 eval cmds=\"$archive_cmds\"
1088 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
1089 for cmd in $cmds; do
1090 IFS="$save_ifs"
1091 $show "$cmd"
1092 $run eval "$cmd" || exit $?
1093 done
1094 IFS="$save_ifs"
1095
1096 # Create links to the real library.
1097 for linkname in $linknames; do
1098 if test "$realname" != "$linkname"; then
1099 $show "(cd $objdir && $LN_S $realname $linkname)"
1100 $run eval '(cd $objdir && $LN_S $realname $linkname)' || exit $?
1101 fi
1102 done
1103
1104 # If -export-dynamic was specified, set the dlname.
1105 if test "$export_dynamic" = yes; then
1106 # On all known operating systems, these are identical.
1107 dlname="$soname"
1108 fi
1109 fi
1110
1111 # Now set the variables for building old libraries.
1112 oldlib="$objdir/$libname.a"
1113 ;;
1114
1115 *.lo | *.o)
1116 if test -n "$link_against_libtool_libs"; then
1117 $echo "$modename: error: cannot link libtool libraries into reloadable objects" 1>&2
1118 exit 1
1119 fi
1120
1121 if test -n "$deplibs"; then
1122 $echo "$modename: warning: \`-l' and \`-L' are ignored while creating objects" 1>&2
1123 fi
1124
1125 if test -n "$dlfiles$dlprefiles"; then
1126 $echo "$modename: warning: \`-dlopen' is ignored while creating objects" 1>&2
1127 # Nullify the symbol file.
1128 compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
1129 finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
1130 fi
1131
1132 if test -n "$rpath"; then
1133 $echo "$modename: warning: \`-rpath' is ignored while creating objects" 1>&2
1134 fi
1135
1136 if test -n "$vinfo"; then
1137 $echo "$modename: warning: \`-version-info' is ignored while creating objects" 1>&2
1138 fi
1139
1140 if test -n "$release"; then
1141 $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2
1142 fi
1143
1144 case "$output" in
1145 *.lo)
1146 if test -n "$objs"; then
1147 $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
1148 exit 1
1149 fi
1150 libobj="$output"
1151 obj=`$echo "X$output" | $Xsed -e 's/\.lo$/.o/'`
1152 ;;
1153 *)
1154 libobj=
1155 obj="$output"
1156 ;;
1157 esac
1158
1159 # Delete the old objects.
1160 $run $rm $obj $libobj
1161
1162 # Create the old-style object.
1163 reload_objs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'`
1164
1165 output="$obj"
1166 eval cmds=\"$reload_cmds\"
1167 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
1168 for cmd in $cmds; do
1169 IFS="$save_ifs"
1170 $show "$cmd"
1171 $run eval "$cmd" || exit $?
1172 done
1173 IFS="$save_ifs"
1174
1175 # Exit if we aren't doing a library object file.
1176 test -z "$libobj" && exit 0
1177
1178 if test "$build_libtool_libs" != yes; then
1179 # Create an invalid libtool object if no PIC, so that we don't
1180 # accidentally link it into a program.
1181 $show "echo timestamp > $libobj"
1182 $run eval "echo timestamp > $libobj" || exit $?
1183 exit 0
1184 fi
1185
1186 if test -n "$pic_flag"; then
1187 # Only do commands if we really have different PIC objects.
1188 reload_objs="$libobjs"
1189 output="$libobj"
1190 eval cmds=\"$reload_cmds\"
1191 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
1192 for cmd in $cmds; do
1193 IFS="$save_ifs"
1194 $show "$cmd"
1195 $run eval "$cmd" || exit $?
1196 done
1197 IFS="$save_ifs"
1198 else
1199 # Just create a symlink.
1200 $show "$LN_S $obj $libobj"
1201 $run $LN_S $obj $libobj || exit 1
1202 fi
1203
1204 exit 0
1205 ;;
1206
1207 *)
1208 if test -n "$vinfo"; then
1209 $echo "$modename: warning: \`-version-info' is ignored while linking programs" 1>&2
1210 fi
1211
1212 if test -n "$release"; then
1213 $echo "$modename: warning: \`-release' is ignored while creating objects" 1>&2
1214 fi
1215
1216 if test -n "$rpath"; then
1217 # If the user specified any rpath flags, then add them.
1218 for libdir in $rpath; do
1219 if test -n "$hardcode_libdir_flag_spec"; then
1220 if test -n "$hardcode_libdir_separator"; then
1221 if test -z "$hardcode_libdirs"; then
1222 # Put the magic libdir with the hardcode flag.
1223 hardcode_libdirs="$libdir"
1224 libdir="@HARDCODE_LIBDIRS@"
1225 else
1226 # Just accumulate the unique libdirs.
1227 case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
1228 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
1229 ;;
1230 *)
1231 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
1232 ;;
1233 esac
1234 libdir=
1235 fi
1236 fi
1237
1238 if test -n "$libdir"; then
1239 eval flag=\"$hardcode_libdir_flag_spec\"
1240
1241 compile_command="$compile_command $flag"
1242 finalize_command="$finalize_command $flag"
1243 fi
1244 elif test -n "$runpath_var"; then
1245 case "$perm_rpath " in
1246 *" $libdir "*) ;;
1247 *) perm_rpath="$perm_rpath $libdir" ;;
1248 esac
1249 fi
1250 done
1251 fi
1252
1253 # Substitute the hardcoded libdirs into the compile commands.
1254 if test -n "$hardcode_libdir_separator"; then
1255 compile_command=`$echo "X$compile_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"`
1256 finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"`
1257 fi
1258
1259 if test -n "$libobjs" && test "$build_old_libs" = yes; then
1260 # Transform all the library objects into standard objects.
1261 compile_command=`$echo "X$compile_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'`
1262 finalize_command=`$echo "X$finalize_command " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'`
1263 fi
1264
1265 if test "$export_dynamic" = yes && test -n "$NM" && test -n "$global_symbol_pipe"; then
1266 dlsyms="${output}S.c"
1267 else
1268 dlsyms=
1269 fi
1270
1271 if test -n "$dlsyms"; then
1272 # Add our own program objects to the preloaded list.
1273 dlprefiles=`$echo "X$objs$dlprefiles " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//'`
1274
1275 # Discover the nlist of each of the dlfiles.
1276 nlist="$objdir/${output}.nm"
1277
1278 if test -d $objdir; then
1279 $show "$rm $nlist ${nlist}T"
1280 $run $rm "$nlist" "${nlist}T"
1281 else
1282 $show "$mkdir $objdir"
1283 $run $mkdir $objdir
1284 status=$?
1285 if test $status -eq 0 || test -d $objdir; then :
1286 else
1287 exit $status
1288 fi
1289 fi
1290
1291 for arg in $dlprefiles; do
1292 $show "extracting global C symbols from \`$arg'"
1293 $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
1294 done
1295
1296 # Parse the name list into a source file.
1297 $show "creating $objdir/$dlsyms"
1298 if test -z "$run"; then
1299 # Make sure we at least have an empty file.
1300 test -f "$nlist" || : > "$nlist"
1301
1302 # Try sorting and uniquifying the output.
1303 if sort "$nlist" | uniq > "$nlist"T; then
1304 mv -f "$nlist"T "$nlist"
1305 wcout=`wc "$nlist" 2>/dev/null`
1306 count=`echo "X$wcout" | $Xsed -e 's/^[ ]*\([0-9][0-9]*\).*$/\1/'`
1307 (test "$count" -ge 0) 2>/dev/null || count=-1
1308 else
1309 $rm "$nlist"T
1310 count=-1
1311 fi
1312
1313 case "$dlsyms" in
1314 "") ;;
1315 *.c)
1316 $echo > "$objdir/$dlsyms" "\
1317 /* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */
1318 /* Generated by $PROGRAM - GNU $PACKAGE $VERSION */
1319
1320 #ifdef __cplusplus
1321 extern \"C\" {
1322 #endif
1323
1324 /* Prevent the only kind of declaration conflicts we can make. */
1325 #define dld_preloaded_symbol_count some_other_symbol
1326 #define dld_preloaded_symbols some_other_symbol
1327
1328 /* External symbol declarations for the compiler. */\
1329 "
1330
1331 if test -f "$nlist"; then
1332 sed -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$objdir/$dlsyms"
1333 else
1334 echo '/* NONE */' >> "$objdir/$dlsyms"
1335 fi
1336
1337 $echo >> "$objdir/$dlsyms" "\
1338
1339 #undef dld_preloaded_symbol_count
1340 #undef dld_preloaded_symbols
1341
1342 #if defined (__STDC__) && __STDC__
1343 # define __ptr_t void *
1344 #else
1345 # define __ptr_t char *
1346 #endif
1347
1348 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
1349 int dld_preloaded_symbol_count = $count;
1350
1351 /* The mapping between symbol names and symbols. */
1352 struct {
1353 char *name;
1354 __ptr_t address;
1355 }
1356 dld_preloaded_symbols[] =
1357 {\
1358 "
1359
1360 if test -f "$nlist"; then
1361 sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$objdir/$dlsyms"
1362 fi
1363
1364 $echo >> "$objdir/$dlsyms" "\
1365 {0, (__ptr_t) 0}
1366 };
1367
1368 #ifdef __cplusplus
1369 }
1370 #endif\
1371 "
1372 ;;
1373
1374 *)
1375 $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
1376 exit 1
1377 ;;
1378 esac
1379 fi
1380
1381 # Now compile the dynamic symbol file.
1382 $show "(cd $objdir && $CC -c$no_builtin_flag \"$dlsyms\")"
1383 $run eval '(cd $objdir && $CC -c$no_builtin_flag "$dlsyms")' || exit $?
1384
1385 # Transform the symbol file into the correct name.
1386 compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"`
1387 finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$objdir/${output}S.o%"`
1388 elif test "$export_dynamic" != yes; then
1389 test -n "$dlfiles$dlprefiles" && $echo "$modename: warning: \`-dlopen' and \`-dlpreopen' are ignored without \`-export-dynamic'" 1>&2
1390 else
1391 # We keep going just in case the user didn't refer to
1392 # dld_preloaded_symbols. The linker will fail if global_symbol_pipe
1393 # really was required.
1394 $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
1395
1396 # Nullify the symbol file.
1397 compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
1398 finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
1399 fi
1400
1401 if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then
1402 # Replace the output file specification.
1403 compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
1404 finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
1405
1406 # We have no uninstalled library dependencies, so finalize right now.
1407 $show "$compile_command"
1408 $run eval "$compile_command"
1409 exit $?
1410 fi
1411
1412 # Replace the output file specification.
1413 compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'%g'`
1414 finalize_command=`$echo "X$finalize_command" | $Xsed -e 's%@OUTPUT@%'"$objdir/$output"'T%g'`
1415
1416 # Create the binary in the object directory, then wrap it.
1417 if test -d $objdir; then :
1418 else
1419 $show "$mkdir $objdir"
1420 $run $mkdir $objdir
1421 status=$?
1422 if test $status -eq 0 || test -d $objdir; then :
1423 else
1424 exit $status
1425 fi
1426 fi
1427
1428 if test -n "$shlibpath_var"; then
1429 # We should set the shlibpath_var
1430 rpath=
1431 for dir in $temp_rpath; do
1432 case "$dir" in
1433 /* | [A-Za-z]:\\*)
1434 # Absolute path.
1435 rpath="$rpath$dir:"
1436 ;;
1437 *)
1438 # Relative path: add a thisdir entry.
1439 rpath="$rpath\$thisdir/$dir:"
1440 ;;
1441 esac
1442 done
1443 temp_rpath="$rpath"
1444 fi
1445
1446 # Delete the old output file.
1447 $run $rm $output
1448
1449 if test -n "$compile_shlibpath"; then
1450 compile_command="$shlibpath_var=\"$compile_shlibpath\$$shlibpath_var\" $compile_command"
1451 fi
1452 if test -n "$finalize_shlibpath"; then
1453 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
1454 fi
1455
1456 if test -n "$runpath_var" && test -n "$perm_rpath"; then
1457 # We should set the runpath_var.
1458 rpath=
1459 for dir in $perm_rpath; do
1460 rpath="$rpath$dir:"
1461 done
1462 compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command"
1463 finalize_command="$runpath_var=\"$rpath\$$runpath_var\" $finalize_command"
1464 fi
1465
1466 if test "$hardcode_action" = relink; then
1467 # AGH! Flame the AIX and HP-UX people for me, will ya?
1468 $echo "$modename: warning: using a buggy system linker" 1>&2
1469 $echo "$modename: relinking will be required before \`$output' can be installed" 1>&2
1470 fi
1471
1472 $show "$compile_command"
1473 $run eval "$compile_command" || exit $?
1474
1475 # Now create the wrapper script.
1476 $show "creating $output"
1477
1478 # Quote the finalize command for shipping.
1479 finalize_command=`$echo "X$finalize_command" | $Xsed -e "$sed_quote_subst"`
1480
1481 # Quote $echo for shipping.
1482 qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
1483
1484 # Only actually do things if our run command is non-null.
1485 if test -z "$run"; then
1486 $rm $output
1487 trap "$rm $output; exit 1" 1 2 15
1488
1489 $echo > $output "\
1490 #! $SHELL
1491
1492 # $output - temporary wrapper script for $objdir/$output
1493 # Generated by $PROGRAM - GNU $PACKAGE $VERSION
1494 #
1495 # The $output program cannot be directly executed until all the libtool
1496 # libraries that it depends on are installed.
1497 #
1498 # This wrapper script should never be moved out of \``pwd`'.
1499 # If it is, it will not operate correctly.
1500
1501 # Sed substitution that helps us do robust quoting. It backslashifies
1502 # metacharacters that are still active within double-quoted strings.
1503 Xsed='sed -e s/^X//'
1504 sed_quote_subst='$sed_quote_subst'
1505
1506 # The HP-UX ksh and POSIX shell print the target directory to stdout
1507 # if CDPATH is set.
1508 if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi
1509
1510 # This environment variable determines our operation mode.
1511 if test \"\$libtool_install_magic\" = \"$magic\"; then
1512 # install mode needs the following variables:
1513 link_against_libtool_libs='$link_against_libtool_libs'
1514 finalize_command=\"$finalize_command\"
1515 else
1516 # When we are sourced in execute mode, \$file and \$echo are already set.
1517 if test \"\$libtool_execute_magic\" = \"$magic\"; then :
1518 else
1519 echo=\"$qecho\"
1520 file=\"\$0\"
1521 fi\
1522 "
1523 $echo >> $output "\
1524
1525 # Find the directory that this script lives in.
1526 thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
1527 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
1528
1529 # Follow symbolic links until we get to the real thisdir.
1530 file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
1531 while test -n \"\$file\"; do
1532 destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
1533
1534 # If there was a directory component, then change thisdir.
1535 if test \"x\$destdir\" != \"x\$file\"; then
1536 case \"\$destdir\" in
1537 /* | [A-Za-z]:\\*) thisdir=\"\$destdir\" ;;
1538 *) thisdir=\"\$thisdir/\$destdir\" ;;
1539 esac
1540 fi
1541
1542 file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
1543 file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
1544 done
1545
1546 # Try to get the absolute directory name.
1547 absdir=\`cd \"\$thisdir\" && pwd\`
1548 test -n \"\$absdir\" && thisdir=\"\$absdir\"
1549
1550 progdir=\"\$thisdir/$objdir\"
1551 program='$output'
1552
1553 if test -f \"\$progdir/\$program\"; then"
1554
1555 # Export our shlibpath_var if we have one.
1556 if test -n "$shlibpath_var" && test -n "$temp_rpath"; then
1557 $echo >> $output "\
1558 # Add our own library path to $shlibpath_var
1559 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
1560
1561 # Some systems cannot cope with colon-terminated $shlibpath_var
1562 $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/:*\$//'\`
1563
1564 export $shlibpath_var
1565 "
1566 fi
1567
1568 $echo >> $output "\
1569 if test \"\$libtool_execute_magic\" != \"$magic\"; then
1570 # Run the actual program with our arguments.
1571
1572 # Export the path to the program.
1573 PATH=\"\$progdir:\$PATH\"
1574 export PATH
1575
1576 exec \$program \${1+\"\$@\"}
1577
1578 \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
1579 exit 1
1580 fi
1581 else
1582 # The program doesn't exist.
1583 \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
1584 \$echo \"This script is just a wrapper for \$program.\" 1>&2
1585 echo \"See the $PACKAGE documentation for more information.\" 1>&2
1586 exit 1
1587 fi
1588 fi\
1589 "
1590 chmod +x $output
1591 fi
1592 exit 0
1593 ;;
1594 esac
1595
1596 # See if we need to build an old-fashioned archive.
1597 if test "$build_old_libs" = "yes"; then
1598 # Transform .lo files to .o files.
1599 oldobjs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'`
1600
1601 # Do each command in the archive commands.
1602 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
1603 eval cmds=\"$old_archive_from_new_cmds\"
1604 else
1605 eval cmds=\"$old_archive_cmds\"
1606 fi
1607 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
1608 for cmd in $cmds; do
1609 IFS="$save_ifs"
1610 $show "$cmd"
1611 $run eval "$cmd" || exit $?
1612 done
1613 IFS="$save_ifs"
1614 fi
1615
1616 # Now create the libtool archive.
1617 case "$output" in
1618 *.la)
1619 old_library=
1620 test "$build_old_libs" = yes && old_library="$libname.a"
1621
1622 $show "creating $output"
1623
1624 # Only create the output if not a dry run.
1625 if test -z "$run"; then
1626 $echo > $output "\
1627 # $output - a libtool library file
1628 # Generated by $PROGRAM - GNU $PACKAGE $VERSION
1629
1630 # The name that we can dlopen(3).
1631 dlname='$dlname'
1632
1633 # Names of this library.
1634 library_names='$library_names'
1635
1636 # The name of the static archive.
1637 old_library='$old_library'
1638
1639 # Libraries that this one depends upon.
1640 dependency_libs='$dependency_libs'
1641
1642 # Version information for $libname.
1643 current=$current
1644 age=$age
1645 revision=$revision
1646
1647 # Directory that this library needs to be installed in:
1648 libdir='$install_libdir'\
1649 "
1650 fi
1651
1652 # Do a symbolic link so that the libtool archive can be found in
1653 # LD_LIBRARY_PATH before the program is installed.
1654 $show "(cd $objdir && $LN_S ../$output $output)"
1655 $run eval "(cd $objdir && $LN_S ../$output $output)" || exit 1
1656 ;;
1657 esac
1658 exit 0
1659 ;;
1660
1661 # libtool install mode
1662 install)
1663 modename="$modename: install"
1664
1665 # There may be an optional sh(1) argument at the beginning of
1666 # install_prog (especially on Windows NT).
1667 if test "$nonopt" = "$SHELL"; then
1668 # Aesthetically quote it.
1669 arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
1670 case "$arg" in
1671 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
1672 arg="\"$arg\""
1673 ;;
1674 esac
1675 install_prog="$arg "
1676 arg="$1"
1677 shift
1678 else
1679 install_prog=
1680 arg="$nonopt"
1681 fi
1682
1683 # The real first argument should be the name of the installation program.
1684 # Aesthetically quote it.
1685 arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1686 case "$arg" in
1687 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
1688 arg="\"$arg\""
1689 ;;
1690 esac
1691 install_prog="$install_prog$arg"
1692
1693 # We need to accept at least all the BSD install flags.
1694 dest=
1695 files=
1696 opts=
1697 prev=
1698 install_type=
1699 isdir=no
1700 stripme=
1701 for arg
1702 do
1703 if test -n "$dest"; then
1704 files="$files $dest"
1705 dest="$arg"
1706 continue
1707 fi
1708
1709 case "$arg" in
1710 -d) isdir=yes ;;
1711 -f) prev="-f" ;;
1712 -g) prev="-g" ;;
1713 -m) prev="-m" ;;
1714 -o) prev="-o" ;;
1715 -s)
1716 stripme=" -s"
1717 continue
1718 ;;
1719 -*) ;;
1720
1721 *)
1722 # If the previous option needed an argument, then skip it.
1723 if test -n "$prev"; then
1724 prev=
1725 else
1726 dest="$arg"
1727 continue
1728 fi
1729 ;;
1730 esac
1731
1732 # Aesthetically quote the argument.
1733 arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1734 case "$arg" in
1735 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
1736 arg="\"$arg\""
1737 ;;
1738 esac
1739 install_prog="$install_prog $arg"
1740 done
1741
1742 if test -z "$install_prog"; then
1743 $echo "$modename: you must specify an install program" 1>&2
1744 $echo "$help" 1>&2
1745 exit 1
1746 fi
1747
1748 if test -n "$prev"; then
1749 $echo "$modename: the \`$prev' option requires an argument" 1>&2
1750 $echo "$help" 1>&2
1751 exit 1
1752 fi
1753
1754 if test -z "$files"; then
1755 if test -z "$dest"; then
1756 $echo "$modename: no file or destination specified" 1>&2
1757 else
1758 $echo "$modename: you must specify a destination" 1>&2
1759 fi
1760 $echo "$help" 1>&2
1761 exit 1
1762 fi
1763
1764 # Strip any trailing slash from the destination.
1765 dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
1766
1767 # Check to see that the destination is a directory.
1768 test -d "$dest" && isdir=yes
1769 if test "$isdir" = yes; then
1770 destdir="$dest"
1771 destname=
1772 else
1773 destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
1774 test "X$destdir" = "X$dest" && destdir=.
1775 destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
1776
1777 # Not a directory, so check to see that there is only one file specified.
1778 set dummy $files
1779 if test $# -gt 2; then
1780 $echo "$modename: \`$dest' is not a directory" 1>&2
1781 $echo "$help" 1>&2
1782 exit 1
1783 fi
1784 fi
1785 case "$destdir" in
1786 /* | [A-Za-z]:\\*) ;;
1787 *)
1788 for file in $files; do
1789 case "$file" in
1790 *.lo) ;;
1791 *)
1792 $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
1793 $echo "$help" 1>&2
1794 exit 1
1795 ;;
1796 esac
1797 done
1798 ;;
1799 esac
1800
1801 # This variable tells wrapper scripts just to set variables rather
1802 # than running their programs.
1803 libtool_install_magic="$magic"
1804
1805 staticlibs=
1806 future_libdirs=
1807 current_libdirs=
1808 for file in $files; do
1809
1810 # Do each installation.
1811 case "$file" in
1812 *.a)
1813 # Do the static libraries later.
1814 staticlibs="$staticlibs $file"
1815 ;;
1816
1817 *.la)
1818 # Check to see that this really is a libtool archive.
1819 if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
1820 else
1821 $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
1822 $echo "$help" 1>&2
1823 exit 1
1824 fi
1825
1826 library_names=
1827 old_library=
1828 # If there is no directory component, then add one.
1829 case "$file" in
1830 */* | *\\*) . $file ;;
1831 *) . ./$file ;;
1832 esac
1833
1834 # Add the libdir to current_libdirs if it is the destination.
1835 if test "X$destdir" = "X$libdir"; then
1836 case "$current_libdirs " in
1837 *" $libdir "*) ;;
1838 *) current_libdirs="$current_libdirs $libdir" ;;
1839 esac
1840 else
1841 # Note the libdir as a future libdir.
1842 case "$future_libdirs " in
1843 *" $libdir "*) ;;
1844 *) future_libdirs="$future_libdirs $libdir" ;;
1845 esac
1846 fi
1847
1848 dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/"
1849 test "X$dir" = "X$file/" && dir=
1850 dir="$dir$objdir"
1851
1852 # See the names of the shared library.
1853 set dummy $library_names
1854 if test -n "$2"; then
1855 realname="$2"
1856 shift
1857 shift
1858
1859 # Install the shared library and build the symlinks.
1860 $show "$install_prog $dir/$realname $destdir/$realname"
1861 $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $?
1862 test "X$dlname" = "X$realname" && dlname=
1863
1864 if test $# -gt 0; then
1865 # Delete the old symlinks.
1866 rmcmd="$rm"
1867 for linkname
1868 do
1869 rmcmd="$rmcmd $destdir/$linkname"
1870 done
1871 $show "$rmcmd"
1872 $run $rmcmd
1873
1874 # ... and create new ones.
1875 for linkname
1876 do
1877 test "X$dlname" = "X$linkname" && dlname=
1878 $show "(cd $destdir && $LN_S $realname $linkname)"
1879 $run eval "(cd $destdir && $LN_S $realname $linkname)"
1880 done
1881 fi
1882
1883 if test -n "$dlname"; then
1884 # Install the dynamically-loadable library.
1885 $show "$install_prog $dir/$dlname $destdir/$dlname"
1886 $run eval "$install_prog $dir/$dlname $destdir/$dlname" || exit $?
1887 fi
1888
1889 # Do each command in the postinstall commands.
1890 lib="$destdir/$realname"
1891 eval cmds=\"$postinstall_cmds\"
1892 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
1893 for cmd in $cmds; do
1894 IFS="$save_ifs"
1895 $show "$cmd"
1896 $run eval "$cmd" || exit $?
1897 done
1898 IFS="$save_ifs"
1899 fi
1900
1901 # Install the pseudo-library for information purposes.
1902 name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
1903 $show "$install_prog $file $destdir/$name"
1904 $run eval "$install_prog $file $destdir/$name" || exit $?
1905
1906 # Maybe install the static library, too.
1907 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
1908 ;;
1909
1910 *.lo)
1911 # Install (i.e. copy) a libtool object.
1912
1913 # Figure out destination file name, if it wasn't already specified.
1914 if test -n "$destname"; then
1915 destfile="$destdir/$destname"
1916 else
1917 destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
1918 destfile="$destdir/$destfile"
1919 fi
1920
1921 # Deduce the name of the destination old-style object file.
1922 case "$destfile" in
1923 *.lo)
1924 staticdest=`$echo "X$destfile" | $Xsed -e 's/\.lo$/.o/'`
1925 ;;
1926 *.o)
1927 staticdest="$destfile"
1928 destfile=
1929 ;;
1930 *)
1931 $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
1932 $echo "$help" 1>&2
1933 exit 1
1934 ;;
1935 esac
1936
1937 # Install the libtool object if requested.
1938 if test -n "$destfile"; then
1939 $show "$install_prog $file $destfile"
1940 $run eval "$install_prog $file $destfile" || exit $?
1941 fi
1942
1943 # Install the old object if enabled.
1944 if test "$build_old_libs" = yes; then
1945 # Deduce the name of the old-style object file.
1946 staticobj=`$echo "X$file" | $Xsed -e 's/\.lo$/.o/'`
1947
1948 $show "$install_prog $staticobj $staticdest"
1949 $run eval "$install_prog \$staticobj \$staticdest" || exit $?
1950 fi
1951 exit 0
1952 ;;
1953
1954 *)
1955 # Figure out destination file name, if it wasn't already specified.
1956 if test -n "$destname"; then
1957 destfile="$destdir/$destname"
1958 else
1959 destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
1960 destfile="$destdir/$destfile"
1961 fi
1962
1963 # Do a test to see if this is really a libtool program.
1964 if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1965 link_against_libtool_libs=
1966 finalize_command=
1967
1968 # If there is no directory component, then add one.
1969 case "$file" in
1970 */* | *\\*) . $file ;;
1971 *) . ./$file ;;
1972 esac
1973
1974 # Check the variables that should have been set.
1975 if test -z "$link_against_libtool_libs" || test -z "$finalize_command"; then
1976 $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
1977 exit 1
1978 fi
1979
1980 finalize=yes
1981 for lib in $link_against_libtool_libs; do
1982 # Check to see that each library is installed.
1983 libdir=
1984 if test -f "$lib"; then
1985 # If there is no directory component, then add one.
1986 case "$lib" in
1987 */* | *\\*) . $lib ;;
1988 *) . ./$lib ;;
1989 esac
1990 fi
1991 libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`"
1992 if test -z "$libdir"; then
1993 $echo "$modename: warning: \`$lib' contains no -rpath information" 1>&2
1994 elif test -f "$libfile"; then :
1995 else
1996 $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
1997 finalize=no
1998 fi
1999 done
2000
2001 if test "$hardcode_action" = relink; then
2002 if test "$finalize" = yes; then
2003 $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2
2004 $show "$finalize_command"
2005 if $run eval "$finalize_command"; then :
2006 else
2007 $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
2008 continue
2009 fi
2010 file="$objdir/$file"T
2011 else
2012 $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2
2013 fi
2014 else
2015 # Install the binary that we compiled earlier.
2016 file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2017 fi
2018 fi
2019
2020 $show "$install_prog$stripme $file $destfile"
2021 $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
2022 ;;
2023 esac
2024 done
2025
2026 for file in $staticlibs; do
2027 name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
2028
2029 # Set up the ranlib parameters.
2030 oldlib="$destdir/$name"
2031
2032 $show "$install_prog $file $oldlib"
2033 $run eval "$install_prog \$file \$oldlib" || exit $?
2034
2035 # Do each command in the postinstall commands.
2036 eval cmds=\"$old_postinstall_cmds\"
2037 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
2038 for cmd in $cmds; do
2039 IFS="$save_ifs"
2040 $show "$cmd"
2041 $run eval "$cmd" || exit $?
2042 done
2043 IFS="$save_ifs"
2044 done
2045
2046 if test -n "$future_libdirs"; then
2047 $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
2048 fi
2049
2050 if test -n "$current_libdirs"; then
2051 # Maybe just do a dry run.
2052 test -n "$run" && current_libdirs=" -n$current_libdirs"
2053 exec $SHELL $0 --finish$current_libdirs
2054 exit 1
2055 fi
2056
2057 exit 0
2058 ;;
2059
2060 # libtool finish mode
2061 finish)
2062 modename="$modename: finish"
2063 libdirs="$nonopt"
2064 admincmds=
2065
2066 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2067 for dir
2068 do
2069 libdirs="$libdirs $dir"
2070 done
2071
2072 for libdir in $libdirs; do
2073 if test -n "$finish_cmds"; then
2074 # Do each command in the finish commands.
2075 eval cmds=\"$finish_cmds\"
2076 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
2077 for cmd in $cmds; do
2078 IFS="$save_ifs"
2079 $show "$cmd"
2080 $run eval "$cmd" || admincmds="$admincmds
2081 $cmd"
2082 done
2083 IFS="$save_ifs"
2084 fi
2085 if test -n "$finish_eval"; then
2086 # Do the single finish_eval.
2087 eval cmds=\"$finish_eval\"
2088 $run eval "$cmds" || admincmds="$admincmds
2089 $cmds"
2090 fi
2091 done
2092 fi
2093
2094 echo "----------------------------------------------------------------------"
2095 echo "Libraries have been installed in:"
2096 for libdir in $libdirs; do
2097 echo " $libdir"
2098 done
2099 echo
2100 echo "To link against installed libraries in a given directory, LIBDIR,"
2101 echo "you must use the \`-LLIBDIR' flag during linking."
2102 echo
2103 echo " You will also need to do at least one of the following:"
2104 if test -n "$shlibpath_var"; then
2105 echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
2106 echo " during execution"
2107 fi
2108 if test -n "$runpath_var"; then
2109 echo " - add LIBDIR to the \`$runpath_var' environment variable"
2110 echo " during linking"
2111 fi
2112 if test -n "$hardcode_libdir_flag_spec"; then
2113 libdir=LIBDIR
2114 eval flag=\"$hardcode_libdir_flag_spec\"
2115
2116 echo " - use the \`$flag' linker flag"
2117 fi
2118 if test -n "$admincmds"; then
2119 echo " - have your system administrator run these commands:$admincmds"
2120 fi
2121 if test -f /etc/ld.so.conf; then
2122 echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2123 fi
2124 echo
2125 echo "See any operating system documentation about shared libraries for"
2126 echo "more information, such as the ld(1) and ld.so(8) manual pages."
2127 echo "----------------------------------------------------------------------"
2128 exit 0
2129 ;;
2130
2131 # libtool execute mode
2132 execute)
2133 modename="$modename: execute"
2134
2135 # The first argument is the command name.
2136 cmd="$nonopt"
2137 if test -z "$cmd"; then
2138 $echo "$modename: you must specify a COMMAND" 1>&2
2139 $echo "$help"
2140 exit 1
2141 fi
2142
2143 # Handle -dlopen flags immediately.
2144 for file in $execute_dlfiles; do
2145 if test -f "$file"; then :
2146 else
2147 $echo "$modename: \`$file' is not a file" 1>&2
2148 $echo "$help" 1>&2
2149 exit 1
2150 fi
2151
2152 dir=
2153 case "$file" in
2154 *.la)
2155 # Check to see that this really is a libtool archive.
2156 if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2157 else
2158 $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2159 $echo "$help" 1>&2
2160 exit 1
2161 fi
2162
2163 # Read the libtool library.
2164 dlname=
2165 library_names=
2166
2167 # If there is no directory component, then add one.
2168 case "$file" in
2169 */* | *\\*) . $file ;;
2170 *) . ./$file ;;
2171 esac
2172
2173 # Skip this library if it cannot be dlopened.
2174 if test -z "$dlname"; then
2175 # Warn if it was a shared library.
2176 test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
2177 continue
2178 fi
2179
2180 dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
2181 test "X$dir" = "X$file" && dir=.
2182
2183 if test -f "$dir/$objdir/$dlname"; then
2184 dir="$dir/$objdir"
2185 else
2186 $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
2187 exit 1
2188 fi
2189 ;;
2190
2191 *.lo)
2192 # Just add the directory containing the .lo file.
2193 dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
2194 test "X$dir" = "X$file" && dir=.
2195 ;;
2196
2197 *)
2198 $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
2199 continue
2200 ;;
2201 esac
2202
2203 # Get the absolute pathname.
2204 absdir=`cd "$dir" && pwd`
2205 test -n "$absdir" && dir="$absdir"
2206
2207 # Now add the directory to shlibpath_var.
2208 if eval "test -z \"\$$shlibpath_var\""; then
2209 eval "$shlibpath_var=\"\$dir\""
2210 else
2211 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2212 fi
2213 done
2214
2215 # This variable tells wrapper scripts just to set shlibpath_var
2216 # rather than running their programs.
2217 libtool_execute_magic="$magic"
2218
2219 # Check if any of the arguments is a wrapper script.
2220 args=
2221 for file
2222 do
2223 case "$file" in
2224 -*) ;;
2225 *)
2226 # Do a test to see if this is really a libtool program.
2227 if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2228 # If there is no directory component, then add one.
2229 case "$file" in
2230 */* | *\\*) . $file ;;
2231 *) . ./$file ;;
2232 esac
2233
2234 # Transform arg to wrapped name.
2235 file="$progdir/$program"
2236 fi
2237 ;;
2238 esac
2239 # Quote arguments (to preserve shell metacharacters).
2240 file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
2241 args="$args \"$file\""
2242 done
2243
2244 if test -z "$run"; then
2245 # Export the shlibpath_var.
2246 eval "export $shlibpath_var"
2247
2248 # Now actually exec the command.
2249 eval "exec \$cmd$args"
2250
2251 $echo "$modename: cannot exec \$cmd$args"
2252 exit 1
2253 else
2254 # Display what would be done.
2255 eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
2256 $echo "export $shlibpath_var"
2257 $echo "$cmd$args"
2258 exit 0
2259 fi
2260 ;;
2261
2262 # libtool uninstall mode
2263 uninstall)
2264 modename="$modename: uninstall"
2265 rm="$nonopt"
2266 files=
2267
2268 for arg
2269 do
2270 case "$arg" in
2271 -*) rm="$rm $arg" ;;
2272 *) files="$files $arg" ;;
2273 esac
2274 done
2275
2276 if test -z "$rm"; then
2277 $echo "$modename: you must specify an RM program" 1>&2
2278 $echo "$help" 1>&2
2279 exit 1
2280 fi
2281
2282 for file in $files; do
2283 dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
2284 test "X$dir" = "X$file" && dir=.
2285 name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
2286
2287 rmfiles="$file"
2288
2289 case "$name" in
2290 *.la)
2291 # Possibly a libtool archive, so verify it.
2292 if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2293 . $dir/$name
2294
2295 # Delete the libtool libraries and symlinks.
2296 for n in $library_names; do
2297 rmfiles="$rmfiles $dir/$n"
2298 test "X$n" = "X$dlname" && dlname=
2299 done
2300 test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname"
2301 test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library"
2302
2303 $show "$rm $rmfiles"
2304 $run $rm $rmfiles
2305
2306 if test -n "$library_names"; then
2307 # Do each command in the postuninstall commands.
2308 eval cmds=\"$postuninstall_cmds\"
2309 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
2310 for cmd in $cmds; do
2311 IFS="$save_ifs"
2312 $show "$cmd"
2313 $run eval "$cmd"
2314 done
2315 IFS="$save_ifs"
2316 fi
2317
2318 if test -n "$old_library"; then
2319 # Do each command in the old_postuninstall commands.
2320 eval cmds=\"$old_postuninstall_cmds\"
2321 IFS="${IFS= }"; save_ifs="$IFS"; IFS=';'
2322 for cmd in $cmds; do
2323 IFS="$save_ifs"
2324 $show "$cmd"
2325 $run eval "$cmd"
2326 done
2327 IFS="$save_ifs"
2328 fi
2329
2330 # FIXME: should reinstall the best remaining shared library.
2331 fi
2332 ;;
2333
2334 *.lo)
2335 if test "$build_old_libs" = yes; then
2336 oldobj=`$echo "X$name" | $Xsed -e 's/\.lo$/.o/'`
2337 rmfiles="$rmfiles $dir/$oldobj"
2338 fi
2339 $show "$rm $rmfiles"
2340 $run $rm $rmfiles
2341 ;;
2342
2343 *)
2344 $show "$rm $rmfiles"
2345 $run $rm $rmfiles
2346 ;;
2347 esac
2348 done
2349 exit 0
2350 ;;
2351
2352 "")
2353 $echo "$modename: you must specify a MODE" 1>&2
2354 $echo "$generic_help" 1>&2
2355 exit 1
2356 ;;
2357 esac
2358
2359 $echo "$modename: invalid operation mode \`$mode'" 1>&2
2360 $echo "$generic_help" 1>&2
2361 exit 1
2362 fi # test -z "$show_help"
2363
2364 # We need to display help for each of the modes.
2365 case "$mode" in
2366 "") $echo \
2367 "Usage: $modename [OPTION]... [MODE-ARG]...
2368
2369 Provide generalized library-building support services.
2370
2371 --config show all configuration variables
2372 --debug enable verbose shell tracing
2373 -n, --dry-run display commands without modifying any files
2374 --features display basic configuration information and exit
2375 --finish same as \`--mode=finish'
2376 --help display this help message and exit
2377 --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
2378 --quiet same as \`--silent'
2379 --silent don't print informational messages
2380 --version print version information
2381
2382 MODE must be one of the following:
2383
2384 compile compile a source file into a libtool object
2385 execute automatically set library path, then run a program
2386 finish complete the installation of libtool libraries
2387 install install libraries or executables
2388 link create a library or an executable
2389 uninstall remove libraries from an installed directory
2390
2391 MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
2392 a more detailed description of MODE."
2393 exit 0
2394 ;;
2395
2396 compile)
2397 $echo \
2398 "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2399
2400 Compile a source file into a libtool library object.
2401
2402 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
2403 from the given SOURCEFILE.
2404
2405 The output file name is determined by removing the directory component from
2406 SOURCEFILE, then substituting the C source code suffix \`.c' with the
2407 library object suffix, \`.lo'."
2408 ;;
2409
2410 execute)
2411 $echo \
2412 "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
2413
2414 Automatically set library path, then run a program.
2415
2416 This mode accepts the following additional options:
2417
2418 -dlopen FILE add the directory containing FILE to the library path
2419
2420 This mode sets the library path environment variable according to \`-dlopen'
2421 flags.
2422
2423 If any of the ARGS are libtool executable wrappers, then they are translated
2424 into their corresponding uninstalled binary, and any of their required library
2425 directories are added to the library path.
2426
2427 Then, COMMAND is executed, with ARGS as arguments."
2428 ;;
2429
2430 finish)
2431 $echo \
2432 "Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
2433
2434 Complete the installation of libtool libraries.
2435
2436 Each LIBDIR is a directory that contains libtool libraries.
2437
2438 The commands that this mode executes may require superuser privileges. Use
2439 the \`--dry-run' option if you just want to see what would be executed."
2440 ;;
2441
2442 install)
2443 $echo \
2444 "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
2445
2446 Install executables or libraries.
2447
2448 INSTALL-COMMAND is the installation command. The first component should be
2449 either the \`install' or \`cp' program.
2450
2451 The rest of the components are interpreted as arguments to that command (only
2452 BSD-compatible install options are recognized)."
2453 ;;
2454
2455 link)
2456 $echo \
2457 "Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
2458
2459 Link object files or libraries together to form another library, or to
2460 create an executable program.
2461
2462 LINK-COMMAND is a command using the C compiler that you would use to create
2463 a program from several object files.
2464
2465 The following components of LINK-COMMAND are treated specially:
2466
2467 -all-static do not do any dynamic linking at all
2468 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
2469 -dlpreopen FILE link in FILE and add its symbols to dld_preloaded_symbols
2470 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2471 -LLIBDIR search LIBDIR for required installed libraries
2472 -lNAME OUTPUT-FILE requires the installed library libNAME
2473 -no-undefined declare that a library does not refer to external symbols
2474 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
2475 -release RELEASE specify package release information
2476 -rpath LIBDIR the created library will eventually be installed in LIBDIR
2477 -static do not do any dynamic linking of libtool libraries
2478 -version-info CURRENT[:REVISION[:AGE]]
2479 specify library version info [each variable defaults to 0]
2480
2481 All other options (arguments beginning with \`-') are ignored.
2482
2483 Every other argument is treated as a filename. Files ending in \`.la' are
2484 treated as uninstalled libtool libraries, other files are standard or library
2485 object files.
2486
2487 If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only
2488 library objects (\`.lo' files) may be specified, and \`-rpath' is required.
2489
2490 If OUTPUT-FILE ends in \`.a', then a standard library is created using \`ar'
2491 and \`ranlib'.
2492
2493 If OUTPUT-FILE ends in \`.lo' or \`.o', then a reloadable object file is
2494 created, otherwise an executable program is created."
2495 ;;
2496
2497 uninstall)
2498 $echo
2499 "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2500
2501 Remove libraries from an installation directory.
2502
2503 RM is the name of the program to use to delete files associated with each FILE
2504 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
2505 to RM.
2506
2507 If FILE is a libtool library, all the files associated with it are deleted.
2508 Otherwise, only FILE itself is deleted using RM."
2509 ;;
2510
2511 *)
2512 $echo "$modename: invalid operation mode \`$mode'" 1>&2
2513 $echo "$help" 1>&2
2514 exit 1
2515 ;;
2516 esac
2517
2518 echo
2519 $echo "Try \`$modename --help' for more information about other modes."
2520
2521 exit 0
2522
2523 # Local Variables:
2524 # mode:shell-script
2525 # sh-indentation:2
2526 # End: