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