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