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