Commit | Line | Data |
---|---|---|
a7a8349d MV |
1 | # ltmain.sh - Provide generalized library-building support services. |
2 | # Generated automatically from ltmain.sh.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 | ||
25 | # The name of this program. | |
26 | progname=`echo "$0" | sed 's%^.*/%%'` | |
27 | ||
28 | # Constants. | |
29 | PROGRAM=ltmain.sh | |
30 | PACKAGE=libtool | |
4cdcd100 | 31 | VERSION=0.9d |
a7a8349d MV |
32 | |
33 | default_mode=NONE | |
34 | help="Try \`$progname --help' for more information." | |
35 | ln_s="ln -s" | |
36 | cp_p="cp -p" | |
37 | magic="%%%MAGIC variable%%%" | |
38 | mkdir="mkdir" | |
39 | mv="mv -f" | |
40 | objdir=.libs | |
41 | rm="rm -f" | |
42 | ||
43 | if test "$LTCONFIG_VERSION" != "$VERSION"; then | |
44 | echo "$progname: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 | |
45 | echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 | |
46 | exit 1 | |
47 | fi | |
48 | ||
4cdcd100 JB |
49 | # |
50 | if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then | |
51 | echo "$progname: not configured to build any kind of library" 1>&2 | |
52 | echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 | |
53 | exit 1 | |
54 | fi | |
55 | ||
a7a8349d MV |
56 | # Global variables. |
57 | mode=$default_mode | |
58 | nonopt= | |
59 | prev= | |
60 | prevopt= | |
61 | run= | |
62 | show=echo | |
63 | show_help= | |
64 | ||
65 | # Parse our command line options once, thoroughly. | |
66 | while test -n "$1" | |
67 | do | |
68 | arg="$1" | |
69 | shift | |
70 | ||
71 | case "$arg" in | |
72 | -*=*) optarg=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;; | |
73 | *) optarg= ;; | |
74 | esac | |
75 | ||
76 | # If the previous option needs an argument, assign it. | |
77 | if test -n "$prev"; then | |
78 | eval "$prev=\$arg" | |
79 | prev= | |
80 | prevopt= | |
81 | continue | |
82 | fi | |
83 | ||
84 | # Have we seen a non-optional argument yet? | |
85 | case "$arg" in | |
86 | --help) | |
87 | show_help=yes | |
88 | ;; | |
89 | ||
90 | --version) | |
91 | echo "$PROGRAM (GNU $PACKAGE) $VERSION" | |
92 | exit 0 | |
93 | ;; | |
94 | ||
95 | --dry-run | -n) | |
96 | run=: | |
97 | ;; | |
98 | ||
96abf47d MD |
99 | --features) |
100 | echo "host: $host" | |
101 | if test "$build_libtool_libs" = yes; then | |
102 | echo "enable shared libraries" | |
103 | else | |
104 | echo "disable shared libraries" | |
105 | fi | |
106 | if test "$build_old_libs" = yes; then | |
107 | echo "enable static libraries" | |
108 | else | |
109 | echo "disable static libraries" | |
110 | fi | |
111 | exit 0 | |
112 | ;; | |
113 | ||
a7a8349d MV |
114 | --finish) mode="finish" ;; |
115 | ||
116 | --mode) prevopt="--mode" prev=mode ;; | |
117 | --mode=*) mode="$optarg" ;; | |
118 | ||
119 | -*) | |
120 | echo "$progname: unrecognized option \`$arg'" 1>&2 | |
121 | echo "$help" 1>&2 | |
122 | exit 1 | |
123 | ;; | |
124 | ||
125 | *) | |
126 | nonopt="$arg" | |
127 | break | |
128 | ;; | |
129 | esac | |
130 | done | |
131 | ||
132 | ||
133 | if test -n "$prevopt"; then | |
134 | echo "$progname: option \`$prevopt' requires an argument" 1>&2 | |
96abf47d | 135 | echo "$help" 1>&2 |
a7a8349d MV |
136 | exit 1 |
137 | fi | |
138 | ||
139 | ||
140 | if test -z "$show_help"; then | |
141 | ||
142 | # Infer the operation mode. | |
143 | if test "$mode" = NONE; then | |
144 | case "$nonopt" in | |
145 | *cc) | |
146 | if echo " $@ " | egrep "[ ]-c[ ]" > /dev/null 2>&1; then | |
147 | mode=compile | |
148 | else | |
149 | mode=link | |
150 | fi | |
151 | ;; | |
152 | *install*|cp) | |
153 | mode=install | |
154 | ;; | |
155 | *rm) | |
156 | mode=uninstall | |
157 | ;; | |
4cdcd100 JB |
158 | *.la) |
159 | mode=dlname | |
160 | ;; | |
a7a8349d MV |
161 | *) |
162 | # Just use the default operation mode. | |
163 | if test "$mode" = NONE; then | |
164 | if test -n "$nonopt"; then | |
4cdcd100 | 165 | echo "$progname: warning: cannot infer operation mode from \`$nonopt'" 1>&2 |
a7a8349d | 166 | else |
4cdcd100 | 167 | echo "$progname: warning: cannot infer operation mode without MODE-ARGS" 1>&2 |
a7a8349d MV |
168 | fi |
169 | fi | |
170 | ;; | |
171 | esac | |
172 | fi | |
173 | ||
174 | # Change the help message to a mode-specific one. | |
175 | generic_help="$help" | |
176 | help="Try \`$progname --help --mode=$mode' for more information." | |
177 | ||
178 | # These modes are in order of execution frequency so that they run quickly. | |
179 | case "$mode" in | |
180 | # libtool compile mode | |
181 | compile) | |
4cdcd100 | 182 | progname="$progname: compile" |
a7a8349d MV |
183 | # Get the compilation command and the source file. |
184 | base_compile="$nonopt" | |
185 | lastarg= | |
186 | srcfile= | |
187 | ||
188 | for arg | |
189 | do | |
190 | # Quote any args containing shell metacharacters. | |
191 | case "$arg" in | |
192 | *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*|*\"*) | |
193 | quote_arg="'$arg'" ;; | |
194 | *) quote_arg="$arg" ;; | |
195 | esac | |
196 | ||
197 | base_compile="$base_compile$lastarg" | |
198 | srcfile="$quote_arg" | |
199 | lastarg=" $srcfile" | |
200 | done | |
201 | ||
202 | # Get the name of the library object. | |
96abf47d MD |
203 | libobj=`echo "$srcfile" | sed -e 's%^.*/%%'` |
204 | ||
205 | # Recognize several different file suffixes. | |
206 | xform='[cCFSf]' | |
207 | case "$libobj" in | |
208 | *.c++) xform='c++' ;; | |
209 | *.cc) xform=cc ;; | |
210 | *.cpp) xform=cpp ;; | |
211 | *.cxx) xform=cxx ;; | |
212 | *.f90) xform=f90 ;; | |
213 | *.for) xform='for' ;; | |
214 | esac | |
215 | ||
216 | libobj=`echo "$libobj" | sed -e "s/\.$xform$/.lo/"` | |
217 | ||
218 | case "$libobj" in | |
a7a8349d MV |
219 | *.lo) obj=`echo "$libobj" | sed -e 's/\.lo$/.o/'` ;; |
220 | *) | |
96abf47d | 221 | echo "$progname: cannot determine name of library object from \`$srcfile'" 1>&2 |
a7a8349d MV |
222 | exit 1 |
223 | ;; | |
224 | esac | |
225 | ||
226 | if test -z "$base_compile"; then | |
227 | echo "$progname: you must specify a compilation command" 1>&2 | |
228 | echo "$help" 1>&2 | |
229 | exit 1 | |
230 | fi | |
231 | ||
232 | # Delete any old library objects. | |
233 | $run $rm $obj $libobj | |
234 | trap "$run $rm $obj $libobj; exit 1" 1 2 15 | |
235 | ||
236 | # Only build a PIC object if we are building libtool libraries. | |
237 | if test "$build_libtool_libs" = yes; then | |
238 | # All platforms use -DPIC, to notify preprocessed assembler code. | |
239 | $show "$base_compile$pic_flag -DPIC $srcfile" | |
240 | if eval "$run $base_compile$pic_flag -DPIC $srcfile"; then : | |
241 | else | |
242 | $run $rm $obj | |
243 | exit 1 | |
244 | fi | |
245 | ||
246 | # If we have no pic_flag, then copy the object into place and finish. | |
247 | if test -z "$pic_flag"; then | |
248 | $show "$ln_s $obj $libobj" | |
249 | $run $ln_s $obj $libobj || $run $cp_p $obj $libobj | |
250 | exit $? | |
251 | fi | |
252 | ||
253 | # Just move the object, then go on to compile the next one | |
254 | $show "$mv $obj $libobj" | |
255 | $run $mv $obj $libobj || exit 1 | |
256 | fi | |
257 | ||
258 | # Compile the position-dependent object. | |
259 | $show "$base_compile $srcfile" | |
260 | if eval "$run $base_compile $srcfile"; then : | |
261 | else | |
262 | $run $rm $obj $libobj | |
263 | exit 1 | |
264 | fi | |
265 | ||
266 | # Symlink or copy the object file into library object, if no PIC. | |
267 | if test "$build_libtool_libs" != yes; then | |
268 | $show "$ln_s $obj $libobj" | |
269 | $run $ln_s $obj $libobj || $run $cp_p $obj $libobj | |
270 | exit $? | |
271 | fi | |
272 | ||
273 | exit 0 | |
274 | ;; | |
275 | ||
276 | # libtool link mode | |
277 | link) | |
4cdcd100 | 278 | progname="$progname: link" |
a7a8349d MV |
279 | # Go through the arguments, transforming them on the way. |
280 | cc="$nonopt" | |
281 | args="$cc" | |
282 | compile_command="$cc" | |
283 | finalize_command="$cc" | |
96abf47d MD |
284 | compile_shlibpath= |
285 | finalize_shlibpath= | |
a7a8349d | 286 | deplibs= |
4cdcd100 JB |
287 | export_dynamic=no |
288 | hardcode_libdirs= | |
a7a8349d MV |
289 | install_libdir= |
290 | libobjs= | |
291 | link_against_libtool_libs= | |
292 | link_static= | |
293 | ltlibs= | |
294 | objs= | |
295 | output= | |
296 | prev= | |
297 | prevarg= | |
298 | temp_rpath= | |
299 | vinfo= | |
4cdcd100 | 300 | whole_archive=no |
a7a8349d | 301 | |
96abf47d MD |
302 | # We need to know -static, to get the right output filenames. |
303 | case " $@ " in | |
4cdcd100 | 304 | *" -static "*) build_libtool_libs=no build_old_libs=yes ;; |
96abf47d MD |
305 | esac |
306 | ||
a7a8349d MV |
307 | for arg |
308 | do | |
309 | # If the previous option needs an argument, assign it. | |
310 | if test -n "$prev"; then | |
311 | case "$prev" in | |
312 | output) | |
4cdcd100 JB |
313 | compile_command="$compile_command @OUTPUT@" |
314 | finalize_command="$finalize_command @OUTPUT@" | |
a7a8349d MV |
315 | args="$args $arg" |
316 | ;; | |
317 | esac | |
318 | ||
319 | eval "$prev=\$arg" | |
320 | prev= | |
321 | ||
322 | continue | |
323 | fi | |
324 | ||
96abf47d MD |
325 | args="$args $arg" |
326 | prevarg="$arg" | |
a7a8349d MV |
327 | |
328 | case "$arg" in | |
4cdcd100 JB |
329 | -export-dynamic) |
330 | export_dynamic=yes | |
331 | compile_command="$compile_command $export_dynamic_flag" | |
332 | finalize_command="$finalize_command $export_dynamic_flag" | |
333 | continue | |
334 | ;; | |
335 | ||
a7a8349d | 336 | -L*) |
a7a8349d MV |
337 | dir=`echo "$arg" | sed 's%^-L\(.*\)$%\1%'` |
338 | case "$dir" in | |
339 | /*) | |
340 | ;; | |
341 | *) | |
342 | echo "$progname: \`-L$dir' cannot specify a relative directory" 1>&2 | |
343 | exit 1 | |
344 | ;; | |
345 | esac | |
96abf47d | 346 | deplibs="$deplibs $arg" |
a7a8349d MV |
347 | ;; |
348 | ||
349 | -l*) deplibs="$deplibs $arg" ;; | |
350 | ||
4cdcd100 JB |
351 | -no-whole-archive) whole_archive=no ;; |
352 | ||
a7a8349d MV |
353 | -o) prev=output ;; |
354 | ||
96abf47d MD |
355 | -rpath) |
356 | prev=install_libdir | |
357 | continue | |
358 | ;; | |
a7a8349d MV |
359 | |
360 | -static) | |
96abf47d MD |
361 | link_static="`eval echo \"$link_static_flag\"`" |
362 | compile_command="$compile_command $link_static" | |
363 | continue | |
a7a8349d MV |
364 | ;; |
365 | ||
366 | -version-file) | |
367 | echo "$progname: \`-version-file' has been replaced by \`-version-info'" 1>&2 | |
368 | echo "$help" 1>&2 | |
369 | exit 1 | |
370 | ;; | |
371 | ||
96abf47d MD |
372 | -version-info) |
373 | prev=vinfo | |
374 | continue | |
375 | ;; | |
a7a8349d | 376 | |
4cdcd100 JB |
377 | -whole-archive) whole_archive=yes ;; |
378 | ||
a7a8349d MV |
379 | -*) cc="$cc $arg" ;; # Some other compiler flag. |
380 | ||
4cdcd100 | 381 | *.o) |
a7a8349d MV |
382 | # A standard object. |
383 | objs="$objs $arg" | |
384 | ;; | |
385 | ||
4cdcd100 JB |
386 | *.a) |
387 | # Find the relevant object directory and library name. | |
388 | file=`echo "$arg" | sed 's%^.*/%%'` | |
389 | dir=`echo "$arg" | sed 's%/[^/]*$%/%'` | |
390 | test "$dir" = "$arg" && dir= | |
391 | ||
392 | # If -whole-archive was specified, we need to link all the members. | |
393 | if test "$whole_archive" = yes; then | |
394 | if test -f $arg; then : | |
395 | else | |
396 | echo "$progname: \`$arg' does not exist" 1>&2 | |
397 | echo "$help" 1>&2 | |
398 | exit 1 | |
399 | fi | |
400 | ||
401 | # Get the names of the members of the archive. | |
402 | members=`$AR t $arg 2>/dev/null` | |
403 | for m in $members; do | |
404 | case "$m" in | |
405 | *.lo) libobjs="$libobjs $dir$m" ;; | |
406 | *.o) | |
407 | if test "$build_libtool_libs" = yes; then | |
408 | objs="$objs $dir$m" | |
409 | else | |
410 | libobjs="$libobjs $dir$m" | |
411 | fi | |
412 | ;; | |
413 | esac | |
414 | done | |
415 | elif test -f "$dir$objdir/$file"; then | |
416 | # .libs/libfoo.a exists, so this is an archive of libobjects. | |
417 | libobjs="$libobjs $arg" | |
418 | else | |
419 | # Standard archive. | |
420 | objs="$objs $arg" | |
421 | fi | |
422 | ;; | |
423 | ||
96abf47d | 424 | *.lo) |
a7a8349d MV |
425 | # A library object. |
426 | libobjs="$libobjs $arg" | |
427 | ;; | |
428 | ||
429 | *.la) | |
430 | # A libtool-controlled library. | |
96abf47d MD |
431 | |
432 | libdir= | |
433 | library_names= | |
434 | old_library= | |
435 | ||
436 | # Check to see that this really is a libtool archive. | |
437 | if egrep "^# Generated by $PROGRAM" $arg >/dev/null 2>&1; then : | |
438 | else | |
439 | echo "$progname: \`$arg' is not a valid libtool archive" 1>&2 | |
440 | exit 1 | |
441 | fi | |
442 | ||
443 | # If there is no directory component, then add one. | |
444 | case "$arg" in | |
445 | */*) . $arg ;; | |
446 | *) . ./$arg ;; | |
447 | esac | |
448 | ||
449 | if test -z "$libdir"; then | |
450 | echo "$progname: \`$arg' contains no -rpath information" 1>&2 | |
451 | exit 1 | |
452 | fi | |
453 | ||
4cdcd100 | 454 | # Get the name of the library we link against. |
96abf47d | 455 | linklib= |
4cdcd100 JB |
456 | for l in $old_library $library_names; do |
457 | linklib="$l" | |
96abf47d MD |
458 | done |
459 | ||
4cdcd100 JB |
460 | if test -z "$linklib"; then |
461 | echo "$progname: cannot find name of link library for \`$arg'" 1>&2 | |
462 | exit 1 | |
463 | fi | |
464 | ||
96abf47d MD |
465 | # Find the relevant object directory and library name. |
466 | name=`echo "$arg" | sed 's%^.*/%%; s/\.la$//; s/^lib//'` | |
a7a8349d | 467 | dir=`echo "$arg" | sed 's%/[^/]*$%%'` |
96abf47d MD |
468 | if test "$dir" = "$arg"; then |
469 | dir="$objdir" | |
470 | else | |
471 | dir="$dir/$objdir" | |
472 | fi | |
a7a8349d MV |
473 | |
474 | link_against_libtool_libs="$link_against_libtool_libs $arg" | |
a7a8349d | 475 | |
96abf47d | 476 | if test "$build_libtool_libs" = yes; then |
a7a8349d MV |
477 | if test -n "$shlibpath_var"; then |
478 | # Make sure the rpath contains only unique directories. | |
479 | case "$temp_rpath " in | |
480 | "* $dir *") ;; | |
481 | *) temp_rpath="$temp_rpath $dir" ;; | |
482 | esac | |
483 | fi | |
484 | ||
4cdcd100 JB |
485 | if test -n "$hardcode_libdir_flag_spec"; then |
486 | if test -n "$hardcode_libdir_separator"; then | |
487 | if test -z "$hardcode_libdirs"; then | |
488 | # Put the magic libdir with the hardcode flag. | |
489 | hardcode_libdirs="$libdir" | |
490 | libdir="@HARDCODE_LIBDIRS@" | |
491 | else | |
492 | # Just accumulate the libdirs. | |
493 | hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" | |
494 | libdir= | |
495 | fi | |
496 | fi | |
a7a8349d | 497 | |
4cdcd100 JB |
498 | if test -n "$libdir"; then |
499 | hardcode_libdir_flag=`eval echo \"$hardcode_libdir_flag_spec\"` | |
500 | compile_command="$compile_command $hardcode_libdir_flag" | |
501 | finalize_command="$finalize_command $hardcode_libdir_flag" | |
502 | fi | |
a7a8349d MV |
503 | fi |
504 | ||
96abf47d | 505 | case "$hardcode_action" in |
4cdcd100 | 506 | immediate) |
96abf47d MD |
507 | if test "$hardcode_direct" = no; then |
508 | compile_command="$compile_command $dir/$linklib" | |
509 | elif test "$hardcode_minus_L" = no; then | |
510 | compile_command="$compile_command -L$dir -l$name" | |
511 | elif test "$hardcode_shlibpath_var" = no; then | |
512 | compile_shlibpath="$compile_shlibpath$dir:" | |
513 | compile_command="$compile_command -l$name" | |
514 | fi | |
515 | ;; | |
a7a8349d | 516 | |
96abf47d MD |
517 | relink) |
518 | # We need an absolute path. | |
a7a8349d | 519 | case "$dir" in |
96abf47d | 520 | /*) ;; |
a7a8349d | 521 | *) |
96abf47d | 522 | absdir=`cd "$dir" && pwd` |
a7a8349d | 523 | if test -z "$absdir"; then |
96abf47d | 524 | echo "$progname: cannot determine absolute directory name of \`$dir'" 1>&2 |
a7a8349d MV |
525 | exit 1 |
526 | fi | |
96abf47d MD |
527 | dir="$absdir" |
528 | ;; | |
529 | esac | |
530 | ||
531 | if test "$hardcode_direct" = yes; then | |
532 | compile_command="$compile_command $dir/$linklib" | |
533 | elif test "$hardcode_minus_L" = yes; then | |
534 | compile_command="$compile_command -L$dir -l$name" | |
535 | elif test "$hardcode_shlibpath_var" = yes; then | |
536 | compile_shlibpath="$compile_shlibpath$dir:" | |
537 | compile_command="$compile_command -l$name" | |
538 | fi | |
539 | ;; | |
4cdcd100 JB |
540 | |
541 | *) | |
542 | echo "$progname: \`$hardcode_action' is an unknown hardcode action" 1>&2 | |
543 | exit 1 | |
544 | ;; | |
96abf47d MD |
545 | esac |
546 | ||
547 | # Finalize command for both is simple: just hardcode it. | |
548 | if test "$hardcode_direct" = yes; then | |
549 | finalize_command="$finalize_command $libdir/$linklib" | |
4cdcd100 | 550 | elif test "$hardcode_minus_L" = yes; then |
96abf47d | 551 | finalize_command="$finalize_command -L$libdir -l$name" |
4cdcd100 | 552 | elif test "$hardcode_shlibpath_var" = yes; then |
96abf47d MD |
553 | finalize_shlibpath="$finalize_shlibpath$libdir:" |
554 | finalize_command="$finalize_command -l$name" | |
4cdcd100 JB |
555 | else |
556 | # We can't seem to hardcode it, guess we'll fake it. | |
557 | finalize_command="$finalize_command -L$libdir -l$name" | |
96abf47d | 558 | fi |
a7a8349d MV |
559 | else |
560 | # Transform directly to old archives if we don't build new libraries. | |
4cdcd100 JB |
561 | test -z "$old_library" || linklib="$old_library" |
562 | compile_command="$compile_command $dir/$linklib" | |
563 | finalize_command="$finalize_command $dir/$linklib" | |
a7a8349d | 564 | fi |
96abf47d | 565 | continue |
a7a8349d MV |
566 | ;; |
567 | ||
568 | *) | |
569 | echo "$progname: unknown file suffix for \`$arg'" 1>&2 | |
96abf47d | 570 | echo "$help" 1>&2 |
a7a8349d MV |
571 | exit 1 |
572 | ;; | |
573 | esac | |
574 | ||
96abf47d MD |
575 | compile_command="$compile_command $arg" |
576 | finalize_command="$finalize_command $arg" | |
a7a8349d MV |
577 | done |
578 | ||
579 | if test -n "$prev"; then | |
96abf47d | 580 | echo "$progname: the \`$prevarg' option requires an argument" 1>&2 |
a7a8349d MV |
581 | echo "$help" 1>&2 |
582 | exit 1 | |
583 | fi | |
584 | ||
4cdcd100 JB |
585 | # Substitute the hardcoded libdirs into the compile commands. |
586 | if test "$hardcode_libdir_colon_separated" = yes; then | |
587 | compile_command=`echo "$compile_command" | sed "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` | |
588 | finalize_command=`echo "$finalize_command" | sed "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` | |
589 | fi | |
590 | ||
a7a8349d MV |
591 | oldlib= |
592 | oldobjs= | |
593 | case "$output" in | |
594 | "") | |
595 | echo "$progname: you must specify an output file" 1>&2 | |
596 | echo "$help" 1>&2 | |
597 | exit 1 | |
598 | ;; | |
599 | ||
600 | */*) | |
601 | echo "$progname: output file \`$output' must have no directory components" 1>&2 | |
602 | exit 1 | |
603 | ;; | |
604 | ||
605 | *.a) | |
606 | # Old archive. | |
4cdcd100 | 607 | libname=`echo "$output" | sed 's/\.a$//'` |
a7a8349d MV |
608 | build_old_libs=yes |
609 | ||
610 | if test -n "$install_libdir"; then | |
611 | echo "$progname: warning: \`-rpath' is ignored while linking old-style libraries" 1>&2 | |
612 | fi | |
613 | ||
614 | if test -n "$vinfo"; then | |
615 | echo "$progname: warning: \`-version-info' is ignored while linking old-style libraries" 1>&2 | |
616 | fi | |
617 | ;; | |
618 | ||
619 | *.la) | |
620 | libname=`echo "$output" | sed 's/\.la$//'` | |
621 | ||
4cdcd100 JB |
622 | # All the library-specific variables (install_libdir is set above). |
623 | library_names= | |
624 | old_library= | |
625 | dlname= | |
626 | current=0 | |
627 | revision=0 | |
628 | age=0 | |
629 | ||
a7a8349d | 630 | if test -n "$objs"; then |
4cdcd100 | 631 | echo "$progname: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 |
a7a8349d MV |
632 | exit 1 |
633 | fi | |
634 | ||
635 | # How the heck are we supposed to write a wrapper for a shared library? | |
636 | if test -n "$link_against_libtool_libs"; then | |
4cdcd100 | 637 | echo "$progname: libtool library \`$output' may not depend on uninstalled libraries:$link_against_libtool_libs" 1>&2 |
a7a8349d MV |
638 | exit 1 |
639 | fi | |
640 | ||
641 | if test -z "$install_libdir"; then | |
642 | echo "$progname: you must specify an installation directory with \`-rpath'" 1>&2 | |
643 | exit 1 | |
644 | fi | |
645 | ||
a7a8349d MV |
646 | # Parse the version information argument. |
647 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' | |
648 | set dummy $vinfo | |
649 | IFS="$save_ifs" | |
650 | ||
651 | if test -n "$5"; then | |
652 | echo "$progname: too many parameters to \`-version-info'" 1>&2 | |
653 | echo "$help" 1>&2 | |
654 | exit 1 | |
655 | fi | |
656 | ||
657 | test -n "$2" && current="$2" | |
658 | test -n "$3" && revision="$3" | |
659 | test -n "$4" && age="$4" | |
660 | ||
661 | # Check that each of the things are valid numbers. | |
662 | case "$current" in | |
663 | 0 | [1-9] | [1-9][0-9]*) ;; | |
664 | *) | |
665 | echo "$progname: CURRENT \`$current' is not a nonnegative integer" 1>&2 | |
666 | echo "$progname: \`$vinfo' is not valid version information" 1>&2 | |
667 | exit 1 | |
668 | ;; | |
669 | esac | |
670 | ||
671 | case "$revision" in | |
672 | 0 | [1-9] | [1-9][0-9]*) ;; | |
673 | *) | |
674 | echo "$progname: REVISION \`$revision' is not a nonnegative integer" 1>&2 | |
675 | echo "$progname: \`$vinfo' is not valid version information" 1>&2 | |
676 | exit 1 | |
677 | ;; | |
678 | esac | |
679 | ||
680 | case "$age" in | |
681 | 0 | [1-9] | [1-9][0-9]*) ;; | |
682 | *) | |
683 | echo "$progname: AGE \`$age' is not a nonnegative integer" 1>&2 | |
684 | echo "$progname: \`$vinfo' is not valid version information" 1>&2 | |
685 | exit 1 | |
686 | ;; | |
687 | esac | |
688 | ||
689 | if test $age -gt $current; then | |
690 | echo "$progname: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 | |
691 | echo "$progname: \`$vinfo' is not valid version information" 1>&2 | |
692 | exit 1 | |
693 | fi | |
694 | ||
695 | # Calculate the version variables. | |
696 | version_vars="version_type current age revision" | |
697 | case "$version_type" in | |
698 | none) ;; | |
699 | ||
a7a8349d MV |
700 | linux) |
701 | version_vars="$version_vars major versuffix" | |
702 | major=`expr $current - $age` | |
703 | versuffix="$major.$age.$revision" | |
704 | ;; | |
705 | ||
706 | osf) | |
707 | version_vars="$version_vars versuffix verstring" | |
96abf47d | 708 | major=`expr $current - $age` |
a7a8349d MV |
709 | versuffix="$current.$age.$revision" |
710 | verstring="$versuffix" | |
711 | ||
712 | # Add in all the interfaces that we are compatible with. | |
713 | loop=$age | |
714 | while test $loop != 0; do | |
715 | iface=`expr $current - $loop` | |
716 | loop=`expr $loop - 1` | |
717 | verstring="$verstring:${iface}.0" | |
718 | done | |
719 | ||
720 | # Make executables depend on our current version. | |
721 | verstring="$verstring:${current}.0" | |
722 | ;; | |
723 | ||
724 | sunos) | |
725 | version_vars="$version_vars major versuffix" | |
726 | major="$current" | |
727 | versuffix="$current.$revision" | |
728 | ;; | |
729 | ||
730 | *) | |
731 | echo "$progname: unknown library version type \`$version_type'" 1>&2 | |
732 | echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 | |
733 | exit 1 | |
734 | ;; | |
735 | esac | |
736 | ||
a7a8349d MV |
737 | # Create the output directory, or remove our outputs if we need to. |
738 | if test -d $objdir; then | |
739 | $show "$rm $objdir/$libname.*" | |
740 | $run $rm $objdir/$libname.* | |
741 | else | |
742 | $show "$mkdir $objdir" | |
743 | $run $mkdir $objdir || exit $? | |
744 | fi | |
745 | ||
746 | if test "$build_libtool_libs" = yes; then | |
747 | # Get the real and link names of the library. | |
4cdcd100 | 748 | library_names=`eval echo \"$library_names_spec\"` |
a7a8349d MV |
749 | set dummy $library_names |
750 | realname="$2" | |
751 | shift; shift | |
752 | ||
753 | if test -n "$soname_spec"; then | |
754 | soname=`eval echo \"$soname_spec\"` | |
755 | else | |
756 | soname="$realname" | |
757 | fi | |
758 | ||
759 | lib="$objdir/$realname" | |
760 | linknames= | |
761 | for link | |
762 | do | |
763 | linknames="$linknames $objdir/$link" | |
764 | done | |
765 | ||
766 | # Use standard objects if they are PIC. | |
96abf47d | 767 | test -z "$pic_flag" && libobjs=`echo "$libobjs " | sed 's/\.lo /.o /g; s/ $//g'` |
a7a8349d MV |
768 | |
769 | # Do each of the archive commands. | |
770 | cmds=`eval echo \"$archive_cmds\"` | |
771 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
772 | for cmd in $cmds; do | |
773 | IFS="$save_ifs" | |
774 | $show "$cmd" | |
775 | eval "$run $cmd" || exit $? | |
776 | done | |
777 | IFS="$save_ifs" | |
778 | ||
779 | # Create links to the real library. | |
780 | for link in $linknames; do | |
781 | $show "$ln_s $realname $link" | |
782 | $run $ln_s $realname $link || exit $? | |
783 | done | |
4cdcd100 JB |
784 | |
785 | # If -export-dynamic was specified, set the dlname. | |
786 | if test "$export_dynamic" = yes; then | |
787 | # On all known operating systems, these are identical. | |
788 | dlname="$soname" | |
789 | fi | |
a7a8349d MV |
790 | fi |
791 | ;; | |
792 | ||
793 | *.lo | *.o) | |
794 | if test -n "$link_against_libtool_libs"; then | |
795 | echo "$progname: error: cannot link libtool libraries into reloadable objects" 1>&2 | |
796 | exit 1 | |
797 | fi | |
798 | ||
799 | if test -n "$deplibs"; then | |
800 | echo "$progname: warning: \`-l' and \`-L' are ignored while creating objects" 1>&2 | |
801 | fi | |
802 | ||
803 | if test -n "$install_libdir"; then | |
804 | echo "$progname: warning: \`-rpath' is ignored while creating objects" 1>&2 | |
805 | fi | |
806 | ||
807 | if test -n "$vinfo"; then | |
808 | echo "$progname: warning: \`-version-info' is ignored while creating objects" 1>&2 | |
809 | fi | |
810 | ||
811 | case "$output" in | |
812 | *.lo) | |
813 | if test -n "$objs"; then | |
814 | echo "$progname: cannot build library object \`$output' from non-libtool objects" 1>&2 | |
815 | exit 1 | |
816 | fi | |
817 | libobj="$output" | |
818 | obj=`echo "$output" | sed 's/\.lo$/.o/'` | |
819 | ;; | |
820 | *) | |
821 | libobj= | |
822 | obj="$output" | |
823 | ;; | |
824 | esac | |
825 | ||
826 | # Delete the old objects. | |
827 | $run $rm $obj $libobj | |
828 | ||
4cdcd100 JB |
829 | # Create the old-style object (skipping any convenience libraries). |
830 | # FIXME: skipping them is simplistic. We should determine which members | |
831 | # are actually needed to resolve symbols. | |
832 | reload_objs="$objs"`echo "$libobjs " | sed 's/[^ ]*\.a //g; s/\.lo /.o /g; s/ $//g'` | |
a7a8349d MV |
833 | |
834 | output="$obj" | |
835 | cmds=`eval echo \"$reload_cmds\"` | |
836 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
837 | for cmd in $cmds; do | |
838 | IFS="$save_ifs" | |
839 | $show "$cmd" | |
840 | eval "$run $cmd" || exit $? | |
841 | done | |
842 | IFS="$save_ifs" | |
843 | ||
844 | # Exit if we aren't doing a library object file. | |
845 | test -z "$libobj" && exit 0 | |
846 | ||
847 | if test "$build_libtool_libs" = yes && test -n "$pic_flag"; then | |
848 | # Only do commands if we really have different PIC objects. | |
849 | reload_objs="$libobjs" | |
850 | output="$libobj" | |
851 | cmds=`eval echo \"$reload_cmds\"` | |
852 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
853 | for cmd in $cmds; do | |
854 | IFS="$save_ifs" | |
855 | $show "$cmd" | |
856 | eval "$run $cmd" || exit $? | |
857 | done | |
858 | IFS="$save_ifs" | |
859 | else | |
860 | # Just create a symlink. | |
861 | $show "$ln_s $obj $libobj" | |
862 | $run $ln_s $obj $libobj || $run $cp_p $obj $libobj || exit 1 | |
863 | fi | |
864 | ||
865 | exit 0 | |
866 | ;; | |
867 | ||
868 | *) | |
869 | if test -n "$install_libdir"; then | |
870 | echo "$progname: warning: \`-rpath' is ignored while linking programs" 1>&2 | |
871 | fi | |
872 | ||
873 | if test -n "$vinfo"; then | |
874 | echo "$progname: warning: \`-version-info' is ignored while linking programs" 1>&2 | |
875 | fi | |
876 | ||
877 | if test -n "$libobjs"; then | |
878 | # Transform all the library objects into standard objects. | |
96abf47d | 879 | compile_command=`echo "$compile_command " | sed 's/\.lo /.o /g; s/ $//'` |
a7a8349d MV |
880 | fi |
881 | ||
882 | if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then | |
4cdcd100 JB |
883 | # Replace the output file specification. |
884 | compile_command=`echo "$compile_command" | sed 's%@OUTPUT@%'"$output"'%g'` | |
885 | finalize_command=`echo "$finalize_command" | sed 's%@OUTPUT@%'"$output"'%g'` | |
886 | ||
a7a8349d | 887 | # We have no uninstalled library dependencies, so finalize right now. |
a7a8349d MV |
888 | $show "$compile_command" |
889 | $run $compile_command | |
96abf47d MD |
890 | status=$? |
891 | ||
892 | # If we failed to link statically, then try again. | |
893 | if test $status -ne 0 && test -n "$link_static"; then | |
894 | echo "$progname: cannot link \`$output' statically; retrying semi-dynamically" 1>&2 | |
895 | compile_command=`echo "$compile_command " | sed "s% $link_static % %;s/ $//"` | |
896 | $show "$finalize_command" | |
897 | $run $finalize_command | |
898 | status=$? | |
899 | fi | |
900 | exit $status | |
a7a8349d MV |
901 | fi |
902 | ||
4cdcd100 JB |
903 | # Replace the output file specification. |
904 | compile_command=`echo "$compile_command" | sed 's%@OUTPUT@%'"$objdir/$output"'%g'` | |
905 | finalize_command=`echo "$finalize_command" | sed 's%@OUTPUT@%'"$objdir/$output"'T%g'` | |
906 | ||
a7a8349d MV |
907 | # Create the binary in the object directory, then wrap it. |
908 | if test -d $objdir; then : | |
909 | else | |
910 | $show "$mkdir $objdir" | |
911 | $run $mkdir $objdir || exit $? | |
912 | fi | |
913 | ||
914 | if test -n "$shlibpath_var"; then | |
915 | # We should set the shlibpath_var | |
916 | rpath= | |
917 | for dir in $temp_rpath; do | |
918 | case "$dir" in | |
919 | /*) | |
920 | # Absolute path. | |
96abf47d | 921 | rpath="$rpath$dir:" |
a7a8349d MV |
922 | ;; |
923 | *) | |
924 | # Relative path: add a thisdir entry. | |
96abf47d | 925 | rpath="$rpath\$thisdir/$dir:" |
a7a8349d MV |
926 | ;; |
927 | esac | |
928 | done | |
a7a8349d MV |
929 | fi |
930 | ||
931 | # Delete the old output file. | |
932 | $run $rm $output | |
933 | ||
96abf47d MD |
934 | if test -n "$compile_shlibpath"; then |
935 | compile_command="$shlibpath_var=$compile_shlibpath\$$shlibpath_var $compile_command" | |
936 | fi | |
937 | if test -n "$finalize_shlibpath"; then | |
938 | finalize_command="$shlibpath_var=$finalize_shlibpath\$$shlibpath_var $finalize_command" | |
939 | fi | |
a7a8349d | 940 | |
96abf47d MD |
941 | case "$hardcode_action" in |
942 | relink) | |
a7a8349d | 943 | # AGH! Flame the AIX and HP-UX people for me, will ya? |
96abf47d | 944 | echo "$progname: warning: using a buggy system linker" 1>&2 |
a7a8349d | 945 | echo "$progname: relinking will be required before \`$output' can be installed" 1>&2 |
96abf47d MD |
946 | ;; |
947 | esac | |
a7a8349d | 948 | |
96abf47d MD |
949 | $show "$compile_command" |
950 | eval "$run $compile_command" || exit $? | |
a7a8349d MV |
951 | |
952 | # Now create the wrapper script. | |
953 | echo "creating $output" | |
954 | ||
955 | # Only actually do things if our run command is non-null. | |
956 | if test -z "$run"; then | |
957 | $rm $output | |
958 | trap "$rm $output; exit 1" 1 2 15 | |
959 | ||
960 | cat > $output <<EOF | |
961 | #! /bin/sh | |
962 | ||
963 | # $output - temporary wrapper script for $objdir/$output | |
964 | # Generated by $PROGRAM - GNU $PACKAGE $VERSION | |
965 | # | |
966 | # The $output program cannot be directly executed until all the libtool | |
967 | # libraries that it depends on are installed. | |
968 | # | |
969 | # This wrapper script should never be moved out of \``pwd`'. | |
970 | # If it is, it will not operate correctly. | |
971 | ||
972 | # This environment variable determines our operation mode. | |
973 | if test "\$libtool_install_magic" = "$magic"; then | |
974 | # install mode needs the following variables: | |
975 | link_against_libtool_libs="$link_against_libtool_libs" | |
976 | finalize_command="$finalize_command" | |
977 | else | |
978 | # Find the directory that this script lives in. | |
979 | thisdir=\`echo \$0 | sed 's%/[^/]*$%%'\` | |
980 | test "x\$thisdir" = "x\$0" && thisdir=. | |
981 | ||
982 | # Try to get the absolute directory name. | |
983 | absdir=\`cd "\$thisdir" && pwd\` | |
984 | test -n "\$absdir" && thisdir="\$absdir" | |
985 | ||
96abf47d MD |
986 | progdir="\$thisdir/$objdir" |
987 | program="$output" | |
988 | ||
989 | if test -f "\$progdir/\$program"; then | |
990 | # Run the actual program with our arguments. | |
991 | args= | |
992 | for arg | |
993 | do | |
994 | # Quote arguments (to preserve shell metacharacters). | |
995 | args="\$args '\$arg'" | |
996 | done | |
997 | ||
998 | # Export the path to the program. | |
999 | PATH="\$progdir:\$PATH" | |
1000 | export PATH | |
a7a8349d MV |
1001 | EOF |
1002 | ||
1003 | # Export our shlibpath_var if we have one. | |
1004 | if test -n "$shlibpath_var" && test -n "$rpath"; then | |
1005 | cat >> $output <<EOF | |
1006 | ||
96abf47d MD |
1007 | # Add our own library path to $shlibpath_var |
1008 | $shlibpath_var="$rpath\$$shlibpath_var" | |
1009 | export $shlibpath_var | |
a7a8349d MV |
1010 | EOF |
1011 | fi | |
1012 | ||
96abf47d | 1013 | cat >> $output <<EOF |
a7a8349d | 1014 | |
a7a8349d MV |
1015 | eval "exec \$program \$args" |
1016 | ||
1017 | echo "\$0: cannot exec \$program \$args" | |
1018 | exit 1 | |
1019 | else | |
1020 | # The program doesn't exist. | |
96abf47d | 1021 | echo "\$0: error: \$progdir/\$program does not exist" 1>&2 |
a7a8349d MV |
1022 | echo "This script is just a wrapper for \$program." 1>&2 |
1023 | echo "See the $PACKAGE documentation for more information." 1>&2 | |
1024 | exit 1 | |
1025 | fi | |
1026 | fi | |
1027 | EOF | |
1028 | chmod +x $output | |
1029 | fi | |
1030 | exit 0 | |
1031 | ;; | |
1032 | esac | |
1033 | ||
1034 | ||
1035 | # See if we need to build an old-fashioned archive. | |
1036 | if test "$build_old_libs" = "yes"; then | |
4cdcd100 JB |
1037 | # Now set the variables for building old libraries. |
1038 | oldlib="$objdir/$libname.a" | |
1039 | ||
1040 | # Transform .lo files to .o (skipping convenience libraries). | |
1041 | # FIXME: skipping them is simplistic. We should determine which members | |
1042 | # are actually needed to resolve symbols. | |
1043 | oldobjs="$objs"`echo "$libobjs " | sed 's/[^ ]*\.a //g; s/\.lo /.o /g; s/ $//g'` | |
1044 | ||
1045 | if test -d "$objdir"; then | |
a7a8349d MV |
1046 | $show "$rm $oldlib" |
1047 | $run $rm $oldlib | |
4cdcd100 JB |
1048 | else |
1049 | $show "$mkdir $objdir" | |
1050 | $run $mkdir $objdir | |
1051 | fi | |
a7a8349d MV |
1052 | |
1053 | # Do each command in the archive commands. | |
1054 | cmds=`eval echo \"$old_archive_cmds\"` | |
1055 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
1056 | for cmd in $cmds; do | |
1057 | IFS="$save_ifs" | |
1058 | $show "$cmd" | |
1059 | eval "$run $cmd" || exit $? | |
1060 | done | |
1061 | IFS="$save_ifs" | |
4cdcd100 JB |
1062 | |
1063 | case "$output" in | |
1064 | *.a) | |
1065 | # Just move into place if there were any non-libtool objects. | |
1066 | if test -n "$objs"; then | |
1067 | $show "$mv $oldlib $output" | |
1068 | $run $mv $oldlib $output | |
1069 | ||
1070 | elif test -z "$pic_flag" || test "$build_libtool_libs" != yes; then | |
1071 | # Just symlink if libtool objects are the same. | |
1072 | $show "$rm $output" | |
1073 | $run $rm $output | |
1074 | $show "$ln_s $oldlib $output" | |
1075 | $run $ln_s $oldlib $output | |
1076 | ||
1077 | else | |
1078 | # Create an archive of libtool objects. | |
1079 | oldlib="$output" | |
1080 | oldobjs="$libobjs" | |
1081 | ||
1082 | # Do each command in the archive commands. | |
1083 | cmds=`eval echo \"$old_archive_cmds\"` | |
1084 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
1085 | for cmd in $cmds; do | |
1086 | IFS="$save_ifs" | |
1087 | $show "$cmd" | |
1088 | eval "$run $cmd" || exit $? | |
1089 | done | |
1090 | IFS="$save_ifs" | |
1091 | fi | |
1092 | ;; | |
1093 | esac | |
a7a8349d MV |
1094 | fi |
1095 | ||
1096 | # Now create the libtool archive. | |
1097 | case "$output" in | |
1098 | *.la) | |
1099 | old_library= | |
1100 | test "$build_old_libs" = yes && old_library="$libname.a" | |
1101 | ||
1102 | echo "creating $output" | |
1103 | ||
1104 | # Only create the output if not a dry run. | |
1105 | if test -z "$run"; then | |
1106 | cat > $output <<EOF | |
1107 | # $output - a libtool library file | |
1108 | # Generated by $PROGRAM - GNU $PACKAGE $VERSION | |
1109 | ||
1110 | # Names of this library. | |
1111 | library_names='$library_names' | |
1112 | ||
1113 | # The name of the static archive. | |
1114 | old_library='$old_library' | |
1115 | ||
4cdcd100 JB |
1116 | # The name that we can dlopen(3). |
1117 | dlname='$dlname' | |
1118 | ||
a7a8349d MV |
1119 | # Version information for $libname. |
1120 | current=$current | |
1121 | age=$age | |
1122 | revision=$revision | |
1123 | ||
1124 | # Directory that this library needs to be installed in: | |
1125 | libdir='$install_libdir' | |
1126 | EOF | |
1127 | fi | |
1128 | ;; | |
1129 | esac | |
1130 | exit 0 | |
1131 | ;; | |
1132 | ||
1133 | # libtool install mode | |
1134 | install) | |
4cdcd100 | 1135 | progname="$progname: install" |
a7a8349d MV |
1136 | |
1137 | # The first argument is the name of the installation program. | |
1138 | install_prog="$nonopt" | |
1139 | ||
1140 | # We need to accept at least all the BSD install flags. | |
1141 | dest= | |
1142 | files= | |
1143 | opts= | |
1144 | prev= | |
1145 | install_type= | |
1146 | isdir= | |
1147 | stripme= | |
1148 | for arg | |
1149 | do | |
1150 | if test -n "$dest"; then | |
1151 | files="$files $dest" | |
1152 | dest="$arg" | |
1153 | continue | |
1154 | fi | |
1155 | ||
1156 | case "$arg" in | |
1157 | -d) isdir=yes ;; | |
1158 | -f) prev="-f" ;; | |
1159 | -g) prev="-g" ;; | |
1160 | -m) prev="-m" ;; | |
1161 | -o) prev="-o" ;; | |
1162 | -s) | |
1163 | stripme=" -s" | |
1164 | continue | |
1165 | ;; | |
1166 | -*) ;; | |
1167 | ||
1168 | *) | |
1169 | # If the previous option needed an argument, then skip it. | |
1170 | if test -n "$prev"; then | |
1171 | prev= | |
1172 | else | |
1173 | dest="$arg" | |
1174 | continue | |
1175 | fi | |
1176 | ;; | |
1177 | esac | |
1178 | install_prog="$install_prog $arg" | |
1179 | done | |
1180 | ||
1181 | if test -z "$install_prog"; then | |
1182 | echo "$progname: you must specify an install program" 1>&2 | |
1183 | echo "$help" 1>&2 | |
1184 | exit 1 | |
1185 | fi | |
1186 | ||
1187 | if test -n "$prev"; then | |
1188 | echo "$progname: the \`$prev' option requires an argument" 1>&2 | |
1189 | echo "$help" 1>&2 | |
1190 | exit 1 | |
1191 | fi | |
1192 | ||
1193 | if test -z "$files"; then | |
1194 | if test -z "$dest"; then | |
1195 | echo "$progname: no file or destination specified" 1>&2 | |
1196 | else | |
1197 | echo "$progname: you must specify a destination" 1>&2 | |
1198 | fi | |
1199 | echo "$help" 1>&2 | |
1200 | exit 1 | |
1201 | fi | |
1202 | ||
1203 | # Strip any trailing slash from the destination. | |
1204 | dest=`echo "$dest" | sed 's%/$%%'` | |
1205 | ||
1206 | # Check to see that the destination is a directory. | |
1207 | test -d "$dest" && isdir=yes | |
1208 | if test -n "$isdir"; then | |
1209 | destdir="$dest" | |
1210 | else | |
1211 | destdir=`echo "$dest" | sed 's%/[^/]*$%%'` | |
1212 | fi | |
1213 | case "$destdir" in | |
1214 | /*) ;; | |
1215 | *) | |
1216 | echo "$progname: $destdir must be an absolute directory name" 1>&2 | |
1217 | echo "$help" 1>&2 | |
1218 | exit 1 | |
1219 | esac | |
1220 | ||
1221 | staticlibs= | |
1222 | future_libdirs= | |
1223 | current_libdirs= | |
1224 | for file in $files; do | |
1225 | ||
1226 | # Do each installation. | |
1227 | case "$file" in | |
1228 | *.a) | |
1229 | # Do the static libraries later. | |
1230 | staticlibs="$staticlibs $file" | |
1231 | ;; | |
1232 | ||
1233 | *.la) | |
1234 | # Check to see that this really is a libtool archive. | |
1235 | if egrep "^# Generated by $PROGRAM" $file >/dev/null 2>&1; then : | |
1236 | else | |
1237 | echo "$progname: \`$file' is not a valid libtool archive" 1>&2 | |
1238 | echo "$help" 1>&2 | |
1239 | exit 1 | |
1240 | fi | |
1241 | ||
1242 | library_names= | |
1243 | old_library= | |
1244 | # If there is no directory component, then add one. | |
1245 | case "$file" in | |
1246 | */*) . $file ;; | |
1247 | *) . ./$file ;; | |
1248 | esac | |
1249 | ||
1250 | # Add the libdir to current_libdirs if it is the destination. | |
1251 | if test "$destdir" = "$libdir"; then | |
1252 | case "$current_libdirs " in | |
1253 | "* $libdir *") ;; | |
1254 | *) current_libdirs="$current_libdirs $libdir" ;; | |
1255 | esac | |
1256 | else | |
1257 | # Note the libdir as a future libdir. | |
1258 | case "$future_libdirs " in | |
1259 | "* $libdir *") ;; | |
1260 | *) future_libdirs="$future_libdirs $libdir" ;; | |
1261 | esac | |
1262 | fi | |
1263 | ||
1264 | dir="`echo "$file" | sed 's%/[^/]*$%%'`/" | |
1265 | test "$dir" = "$file/" && dir= | |
1266 | dir="$dir$objdir" | |
1267 | ||
1268 | # See the names of the shared library. | |
1269 | set dummy $library_names | |
1270 | if test -n "$2"; then | |
1271 | realname="$2" | |
1272 | shift | |
1273 | shift | |
1274 | ||
1275 | # Install the shared library and build the symlinks. | |
1276 | $show "$install_prog $dir/$realname $destdir/$realname" | |
1277 | eval "$run $install_prog $dir/$realname $destdir/$realname" || exit $? | |
4cdcd100 | 1278 | test "X$dlname" = "X$realname" && dlname= |
a7a8349d MV |
1279 | |
1280 | # Support stripping libraries. | |
1281 | if test -n "$stripme"; then | |
1282 | if test -n "$striplib"; then | |
1283 | $show "$striplib $destdir/$realname" | |
1284 | $run $striplib $destdir/$realname || exit $? | |
1285 | else | |
1286 | echo "$progname: warning: no library stripping program" 1>&2 | |
1287 | fi | |
1288 | fi | |
1289 | ||
1290 | if test -n "$1"; then | |
1291 | # Delete the old symlinks. | |
1292 | rmcmd="$rm" | |
1293 | for linkname | |
1294 | do | |
1295 | rmcmd="$rmcmd $destdir/$linkname" | |
1296 | done | |
1297 | $show "$rmcmd" | |
1298 | $run $rmcmd | |
1299 | ||
1300 | # ... and create new ones. | |
1301 | for linkname | |
1302 | do | |
4cdcd100 | 1303 | test "X$dlname" = "X$linkname" && dlname= |
a7a8349d MV |
1304 | $show "$ln_s $realname $destdir/$linkname" |
1305 | $run $ln_s $realname $destdir/$linkname | |
1306 | done | |
1307 | fi | |
1308 | ||
4cdcd100 JB |
1309 | if test -n "$dlname"; then |
1310 | # Install the dynamically-loadable library. | |
1311 | $show "$install_prog $dir/$dlname $destdir/$dlname" | |
1312 | eval "$run $install_prog $dir/$dlname $destdir/$dlname" || exit $? | |
1313 | fi | |
1314 | ||
a7a8349d MV |
1315 | # Do each command in the postinstall commands. |
1316 | lib="$destdir/$realname" | |
1317 | cmds=`eval echo \"$postinstall_cmds\"` | |
1318 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
1319 | for cmd in $cmds; do | |
1320 | IFS="$save_ifs" | |
1321 | $show "$cmd" | |
1322 | eval "$run $cmd" || exit $? | |
1323 | done | |
1324 | IFS="$save_ifs" | |
1325 | fi | |
1326 | ||
1327 | # Install the pseudo-library for information purposes. | |
1328 | name=`echo "$file" | sed 's%^.*/%%'` | |
1329 | $show "$install_prog $file $destdir/$name" | |
1330 | $run $install_prog $file $destdir/$name || exit $? | |
1331 | ||
1332 | # Maybe install the static library, too. | |
1333 | test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" | |
1334 | ;; | |
1335 | ||
1336 | *) | |
1337 | # Do a test to see if this is really a libtool program. | |
1338 | if egrep "^# Generated by $PROGRAM" $file >/dev/null 2>&1; then | |
1339 | # This variable tells wrapper scripts just to set variables rather | |
1340 | # than running their programs. | |
1341 | libtool_install_magic="$magic" | |
1342 | link_against_libtool_libs= | |
1343 | finalize_command= | |
1344 | ||
1345 | # If there is no directory component, then add one. | |
1346 | case "$file" in | |
1347 | */*) . $file ;; | |
1348 | *) . ./$file ;; | |
1349 | esac | |
1350 | ||
1351 | # Check the variables that should have been set. | |
1352 | if test -z "$link_against_libtool_libs" || test -z "$finalize_command"; then | |
96abf47d | 1353 | echo "$progname: invalid libtool wrapper script \`$file'" 1>&2 |
a7a8349d MV |
1354 | exit 1 |
1355 | fi | |
1356 | ||
1357 | finalize=yes | |
1358 | for lib in $link_against_libtool_libs; do | |
1359 | # Check to see that each library is installed. | |
1360 | libdir= | |
1361 | if test -f "$lib"; then | |
1362 | # If there is no directory component, then add one. | |
1363 | case "$lib" in | |
1364 | */*) . $lib ;; | |
1365 | *) . ./$lib ;; | |
1366 | esac | |
1367 | fi | |
1368 | libfile="$libdir/`echo "$lib" | sed 's%^.*/%%g'`" | |
1369 | if test -z "$libdir"; then | |
96abf47d MD |
1370 | echo "$progname: warning: \`$lib' contains no -rpath information" 1>&2 |
1371 | elif test -f "$libfile"; then : | |
a7a8349d MV |
1372 | else |
1373 | echo "$progname: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 | |
1374 | finalize=no | |
1375 | fi | |
1376 | done | |
1377 | ||
96abf47d | 1378 | if test "$hardcode_direct" != no && test "$hardcode_minus_L" != no && test "$hardcode_shlibpath_var" != no; then |
a7a8349d | 1379 | if test "$finalize" = no; then |
96abf47d | 1380 | echo "$progname: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 |
a7a8349d | 1381 | else |
96abf47d | 1382 | echo "$progname: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2 |
a7a8349d MV |
1383 | $show "$finalize_command" |
1384 | if $run $finalize_command; then : | |
1385 | else | |
1386 | echo "$progname: error: relink \`$file' with the above command before installing it" 1>&2 | |
1387 | continue | |
1388 | fi | |
1389 | file="$objdir/$file"T | |
1390 | fi | |
1391 | else | |
1392 | # Install the binary that we compiled earlier. | |
1393 | dir=`echo "$file" | sed 's%/[^/]*$%%'` | |
1394 | if test "$file" = "$dir"; then | |
1395 | file="$objdir/$file" | |
1396 | else | |
1397 | file="$dir/$objdir/`echo "$file" | sed 's%^.*/%%'`" | |
1398 | fi | |
1399 | fi | |
1400 | fi | |
1401 | ||
1402 | $show "$install_prog$stripme $file $dest" | |
1403 | $run $install_prog$stripme $file $dest || exit $? | |
1404 | ;; | |
1405 | esac | |
1406 | done | |
96abf47d | 1407 | |
a7a8349d MV |
1408 | for file in $staticlibs; do |
1409 | name=`echo "$file" | sed 's%^.*/%%'` | |
1410 | ||
1411 | # Set up the ranlib parameters. | |
1412 | oldlib="$destdir/$name" | |
1413 | ||
1414 | $show "$install_prog $file $oldlib" | |
1415 | $run $install_prog $file $oldlib || exit $? | |
1416 | ||
1417 | # Support stripping libraries. | |
1418 | if test -n "$stripme"; then | |
1419 | if test -n "$old_striplib"; then | |
1420 | $show "$old_striplib $oldlib" | |
1421 | $run $old_striplib $oldlib || exit $? | |
1422 | else | |
1423 | echo "$progname: warning: no static library stripping program" 1>&2 | |
1424 | fi | |
1425 | fi | |
1426 | ||
1427 | # Do each command in the postinstall commands. | |
1428 | cmds=`eval echo \"$old_postinstall_cmds\"` | |
1429 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
1430 | for cmd in $cmds; do | |
1431 | IFS="$save_ifs" | |
1432 | $show "$cmd" | |
1433 | eval "$run $cmd" || exit $? | |
1434 | done | |
1435 | IFS="$save_ifs" | |
1436 | done | |
1437 | ||
1438 | if test -n "$future_libdirs"; then | |
96abf47d | 1439 | echo "$progname: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 |
a7a8349d MV |
1440 | fi |
1441 | ||
1442 | if test -n "$current_libdirs"; then | |
1443 | # Maybe just do a dry run. | |
1444 | test -n "$run" && current_libdirs=" -n$current_libdirs" | |
1445 | exec $0 --finish$current_libdirs | |
1446 | exit 1 | |
1447 | fi | |
1448 | ||
1449 | exit 0 | |
1450 | ;; | |
1451 | ||
4cdcd100 JB |
1452 | # libtool dlname mode |
1453 | dlname) | |
1454 | progname="$progname: dlname" | |
1455 | ltlibs="$nonopt" | |
1456 | for lib | |
1457 | do | |
1458 | ltlibs="$ltlibs $lib" | |
1459 | done | |
1460 | ||
1461 | # Now check to make sure each one is a valid libtool library. | |
1462 | status=0 | |
1463 | for lib in $ltlibs; do | |
1464 | dlname= | |
1465 | libdir= | |
1466 | ||
1467 | # Check to see that this really is a libtool archive. | |
1468 | if egrep "^# Generated by $PROGRAM" $arg >/dev/null 2>&1; then : | |
1469 | else | |
1470 | echo "$progname: \`$arg' is not a valid libtool archive" 1>&2 | |
1471 | status=1 | |
1472 | continue | |
1473 | fi | |
1474 | ||
1475 | # If there is no directory component, then add one. | |
1476 | case "$arg" in | |
1477 | */*) . $arg ;; | |
1478 | *) . ./$arg ;; | |
1479 | esac | |
1480 | ||
1481 | if test -z "$libdir"; then | |
1482 | echo "$progname: \`$arg' contains no -rpath information" 1>&2 | |
1483 | status=1 | |
1484 | elif test -n "$dlname"; then | |
1485 | echo "$libdir/$dlname" | |
1486 | else | |
1487 | echo "$progname: \`$arg' was not linked with \`-export-dynamic'" 1>&2 | |
1488 | status=1 | |
1489 | fi | |
1490 | done | |
1491 | exit $status | |
1492 | ;; | |
1493 | ||
a7a8349d MV |
1494 | # libtool finish mode |
1495 | finish) | |
4cdcd100 | 1496 | progname="$progname: finish" |
a7a8349d MV |
1497 | libdirs="$nonopt" |
1498 | ||
1499 | if test -n "$finish_cmds" && test -n "$libdirs"; then | |
1500 | for dir | |
1501 | do | |
1502 | libdirs="$libdirs $dir" | |
1503 | done | |
1504 | ||
1505 | for libdir in $libdirs; do | |
1506 | # Do each command in the postinstall commands. | |
1507 | cmds=`eval echo \"$finish_cmds\"` | |
1508 | IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' | |
1509 | for cmd in $cmds; do | |
1510 | IFS="$save_ifs" | |
1511 | $show "$cmd" | |
1512 | eval "$run $cmd" | |
1513 | done | |
1514 | IFS="$save_ifs" | |
1515 | done | |
1516 | fi | |
1517 | ||
1518 | echo "To link against installed libraries in LIBDIR, users may have to:" | |
1519 | if test -n "$shlibpath_var"; then | |
1520 | echo " - add LIBDIR to their \`$shlibpath_var' environment variable" | |
1521 | fi | |
1522 | echo " - use the \`-LLIBDIR' linker flag" | |
1523 | exit 0 | |
1524 | ;; | |
1525 | ||
1526 | # libtool uninstall mode | |
1527 | uninstall) | |
4cdcd100 | 1528 | progname="$progname: uninstall" |
a7a8349d MV |
1529 | rm="$nonopt" |
1530 | files= | |
1531 | ||
1532 | for arg | |
1533 | do | |
1534 | case "$arg" in | |
1535 | -*) rm="$rm $arg" ;; | |
1536 | *) files="$files $arg" ;; | |
1537 | esac | |
1538 | done | |
1539 | ||
1540 | if test -z "$rm"; then | |
1541 | echo "$progname: you must specify an RM program" 1>&2 | |
1542 | echo "$help" 1>&2 | |
1543 | exit 1 | |
1544 | fi | |
1545 | ||
1546 | for file in $files; do | |
1547 | dir=`echo "$file" | sed -e 's%/[^/]*$%%'` | |
1548 | test "$dir" = "$file" && dir=. | |
1549 | name=`echo "$file" | sed -e 's%^.*/%%'` | |
1550 | ||
4cdcd100 JB |
1551 | rmfiles="$file" |
1552 | ||
a7a8349d MV |
1553 | case "$name" in |
1554 | *.la) | |
1555 | # Possibly a libtool archive, so verify it. | |
1556 | if egrep "^# Generated by $PROGRAM" $file >/dev/null 2>&1; then | |
1557 | . $dir/$name | |
1558 | ||
1559 | # Delete the libtool libraries and symlinks. | |
1560 | for n in $library_names; do | |
4cdcd100 JB |
1561 | rmfiles="$rmfiles $dir/$n" |
1562 | test "X$n" = "X$dlname" && dlname= | |
a7a8349d | 1563 | done |
4cdcd100 JB |
1564 | test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname" |
1565 | test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" | |
a7a8349d | 1566 | |
4cdcd100 | 1567 | # FIXME: should reinstall the best remaining shared library. |
a7a8349d MV |
1568 | fi |
1569 | ;; | |
1570 | esac | |
1571 | ||
4cdcd100 JB |
1572 | $show "$rm $rmfiles" |
1573 | $run $rm $rmfiles | |
a7a8349d | 1574 | done |
96abf47d | 1575 | exit 0 |
a7a8349d MV |
1576 | ;; |
1577 | ||
1578 | NONE) | |
1579 | echo "$progname: you must specify a MODE" 1>&2 | |
1580 | echo "$generic_help" 1>&2 | |
1581 | exit 1 | |
1582 | ;; | |
1583 | esac | |
1584 | ||
1585 | echo "$progname: invalid operation mode \`$mode'" 1>&2 | |
1586 | echo "$generic_help" 1>&2 | |
1587 | exit 1 | |
1588 | fi # test -z "$show_help" | |
1589 | ||
1590 | # We need to display help for each of the modes. | |
1591 | case "$mode" in | |
1592 | NONE) cat <<EOF | |
1593 | Usage: $progname [OPTION]... [MODE-ARG]... | |
1594 | ||
1595 | Provide generalized library-building support services. | |
1596 | ||
1597 | -n, --dry-run display commands without modifying any files | |
96abf47d | 1598 | --features display configuration information and exit |
a7a8349d MV |
1599 | --finish same as \`--mode=finish' |
1600 | --help display this help message and exit | |
1601 | --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] | |
1602 | --version print version information | |
1603 | ||
1604 | MODE must be one of the following: | |
1605 | ||
1606 | compile compile a source file into a libtool object | |
4cdcd100 | 1607 | dlname print filenames to use to \`dlopen' libtool libraries |
a7a8349d MV |
1608 | finish complete the installation of libtool libraries |
1609 | install install libraries or executables | |
1610 | link create a library or an executable | |
1611 | uninstall remove libraries from an installed directory | |
1612 | ||
1613 | MODE-ARGS vary depending on the MODE. Try \`$progname --help --mode=MODE' for | |
1614 | a more detailed description of MODE. | |
1615 | EOF | |
1616 | ;; | |
1617 | ||
1618 | compile) | |
1619 | cat <<EOF | |
1620 | Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE | |
1621 | ||
1622 | Compile a source file into a libtool library object. | |
1623 | ||
1624 | COMPILE-COMMAND is a command to be used in creating a \`standard' object file | |
1625 | from the given SOURCEFILE. | |
1626 | ||
1627 | The output file name is determined by removing the directory component from | |
1628 | SOURCEFILE, then substituting the C source code suffix \`.c' with the | |
1629 | library object suffix, \`.lo'. | |
1630 | EOF | |
1631 | ;; | |
1632 | ||
4cdcd100 JB |
1633 | dlname) |
1634 | cat <<EOF | |
1635 | Usage: $progname [OPTION]... --mode=dlname LTLIBRARY [LTLIBRARY]... | |
1636 | ||
1637 | Print filenames to use to \`dlopen' libtool libraries. | |
1638 | ||
1639 | Each LTLIBRARY is the name of a dynamically loadable libtool library (one that | |
1640 | was linked using the \`-export-dynamic' option). | |
1641 | ||
1642 | The names to use are printed to standard output, one per line. | |
1643 | EOF | |
1644 | ;; | |
1645 | ||
a7a8349d MV |
1646 | finish) |
1647 | cat <<EOF | |
1648 | Usage: $progname [OPTION]... --mode=finish [LIBDIR]... | |
1649 | ||
1650 | Complete the installation of libtool libraries. | |
1651 | ||
1652 | Each LIBDIR is a directory that contains libtool libraries. | |
1653 | ||
1654 | The commands that this mode executes may require superuser privileges. Use | |
1655 | the \`--dry-run' option if you just want to see what would be executed. | |
1656 | EOF | |
1657 | ;; | |
1658 | ||
1659 | install) | |
1660 | cat <<EOF | |
1661 | Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... | |
1662 | ||
1663 | Install executables or libraries. | |
1664 | ||
1665 | INSTALL-COMMAND is the installation command. The first component should be | |
1666 | either the \`install' or \`cp' program. | |
1667 | ||
1668 | The rest of the components are interpreted as arguments to that command (only | |
1669 | BSD-compatible install options are recognized). | |
1670 | EOF | |
1671 | ;; | |
1672 | ||
1673 | link) | |
1674 | cat <<EOF | |
1675 | Usage: $progname [OPTION]... --mode=link LINK-COMMAND... | |
1676 | ||
1677 | Link object files or libraries together to form another library, or to | |
1678 | create an executable program. | |
1679 | ||
1680 | LINK-COMMAND is a command using the C compiler that you would use to create | |
1681 | a program from several object files. | |
1682 | ||
1683 | The following components of LINK-COMMAND are treated specially: | |
1684 | ||
4cdcd100 JB |
1685 | -export-dynamic allow the output file to be loaded with dlopen(3) |
1686 | -LLIBDIR search LIBDIR for required installed libraries | |
1687 | -lNAME OUTPUT-FILE requires the installed library libNAME | |
1688 | -no-whole-archive turn off \`-whole-archive' | |
1689 | -o OUTPUT-FILE create OUTPUT-FILE from the specified objects | |
1690 | -rpath LIBDIR the created library will eventually be installed in LIBDIR | |
1691 | -static do not do any dynamic linking or shared library creation | |
a7a8349d | 1692 | -version-info CURRENT[:REVISION[:AGE]] |
4cdcd100 JB |
1693 | specify library version info [each variable defaults to 0] |
1694 | -whole-archive use all members from subsequent \`.a' files | |
a7a8349d MV |
1695 | |
1696 | All other options (arguments beginning with \`-') are ignored. | |
1697 | ||
1698 | Every other argument is treated as a filename. Files ending in \`.la' are | |
1699 | treated as uninstalled libtool libraries, other files are standard or library | |
1700 | object files. | |
1701 | ||
1702 | If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only | |
96abf47d | 1703 | library objects (\`.lo' files) may be specified, and \`-rpath' is required. |
a7a8349d MV |
1704 | |
1705 | If OUTPUT-FILE ends in \`.a', then a standard library is created using \`ar' | |
4cdcd100 JB |
1706 | and \`ranlib'. If only libtool objects are specified, then the output file |
1707 | may be used in the creation of other libtool archives. | |
a7a8349d MV |
1708 | |
1709 | If OUTPUT-FILE ends in \`.lo' or \`.o', then a reloadable object file is | |
1710 | created, otherwise an executable program is created. | |
1711 | EOF | |
1712 | ;; | |
1713 | ||
1714 | uninstall) | |
1715 | cat <<EOF | |
1716 | Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... | |
1717 | ||
1718 | Remove libraries from an installation directory. | |
1719 | ||
1720 | RM is the name of the program to use to delete files associated with each FILE | |
1721 | (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed | |
1722 | to RM. | |
1723 | ||
1724 | If FILE is a libtool library, all the files associated with it are deleted. | |
1725 | Otherwise, only FILE itself is deleted using RM. | |
1726 | EOF | |
1727 | ;; | |
1728 | ||
1729 | *) | |
1730 | echo "$progname: invalid operation mode \`$mode'" 1>&2 | |
1731 | echo "$help" 1>&2 | |
1732 | exit 1 | |
1733 | ;; | |
1734 | esac | |
1735 | ||
1736 | case "$mode" in | |
1737 | archive|compile) | |
1738 | echo | |
1739 | echo "Try \`$progname --help' for more information about other modes." | |
1740 | ;; | |
1741 | esac | |
1742 | ||
1743 | exit 0 | |
1744 | ||
1745 | # Local Variables: | |
1746 | # mode:shell-script | |
1747 | # sh-indentation:2 | |
1748 | # End: |