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