3000
|
1 #!/bin/sh |
|
2 # This purports to allow distributions to be built with shared libraries. |
|
3 # |
|
4 # I wrote it for Kpathsea and friends, but I don't think there's |
|
5 # anything TeX-specific in here. |
|
6 # |
|
7 # There is a much fancier libtool project underway by |
|
8 # <gord@enci.ucalgary.ca>, but I did not want to wait for that to be |
|
9 # completed, stable, and portable before releasing Web2c. The ideas are |
|
10 # based on Gord's Libtool, though, and you may find its documentation |
|
11 # interesting/useful reading. |
|
12 # |
|
13 # Porting this to other systems shouldn't be too hard, mostly because I |
|
14 # don't try to take advantage of all the fancy features offered by some |
|
15 # os's (like multiple version compatibility, encoding directory paths in |
|
16 # the binary, etc.) See the configure mode. I can send you the |
|
17 # hello,world Makefile I used for testing if you want it. |
|
18 # |
|
19 rcs_version='$Id: klibtool,v 1.1 1997-05-23 03:09:13 jwe Exp $' |
|
20 version=0.1 |
|
21 maint=tex-k@mail.tug.org |
|
22 help="Usage: $0 [OPTION]... MODE [ARG]... |
|
23 Help for building and linking with shared libraries. |
|
24 |
|
25 Modes: Environment variables used: |
|
26 configure [HOSTTYPE] RANLIB, LIBTOOL_OBJTYPES |
|
27 compile CC SOURCEFILE ARG... |
|
28 archive AR ARFLAGS LIBNAME ARG... |
|
29 link CC ARG... |
|
30 install-lib DIR LIBNAME... INSTALL_DATA |
|
31 install-prog DIR PROGNAME... INSTALL_PROGRAM |
|
32 version |
|
33 |
|
34 Options: |
|
35 --config-dir DIR |
|
36 -n, --dry-run |
|
37 --help |
|
38 --quiet, --silent |
|
39 -v, --verbose |
|
40 --version |
|
41 |
|
42 Email bugs to $maint. |
|
43 " |
|
44 |
|
45 bug_report="$0: Please report this bug to $maint. |
|
46 Please mention this is Klibtool version $version ($rcs_version), |
|
47 and your hardware/operating system (`uname -a`, at least). |
|
48 |
|
49 Running this same command ($0 $*) with --verbose and including the |
|
50 resulting output would be nice, but is not required." |
|
51 |
|
52 verbose=: |
|
53 chicken= |
|
54 show=echo |
|
55 config_dir= |
|
56 |
|
57 # Yes, this option parsing is imperfect, e.g., -xcruddy will be |
|
58 # recognized as --config-dir. I don't think it's worth the trouble to |
|
59 # program correctly until somebody besides me uses this. |
|
60 while test $# -gt 0; do |
|
61 case "$1" in |
|
62 configure|compile|archive|link|install-lib|install-prog|version) |
|
63 mode=$1; break;; |
|
64 -*c*) # --config-dir |
|
65 shift; config_dir=$1;; |
|
66 -n|-*d*) # -n, --dry-run |
|
67 chicken=echo;; |
|
68 -*help) # --help |
|
69 echo "$help"; exit 0;; |
|
70 -*q|-*s) # --quiet, --silent |
|
71 show=:; verbose=:;; |
|
72 -v|-*verb*) # --verbose |
|
73 verbose=echo;; |
|
74 -*version) # --version |
|
75 echo "$0 version $version ($rcs_version)"; exit 0;; |
|
76 -*) |
|
77 echo "$0: Unknown option \`$1'. Try --help for info." >&2; exit 1;; |
|
78 *) |
|
79 echo "$0: Unknown mode \`$1'. Try --help for info." >&2; exit 1;; |
|
80 esac |
|
81 shift |
|
82 done |
|
83 |
|
84 # Read all the arguments. Peel off the mode. |
|
85 shift |
|
86 |
|
87 # |
|
88 # Read the configuration file unless we're configuring. |
|
89 # |
|
90 if test $mode != configure; then |
|
91 # Read configuration file. If we have it in the current directory, or |
|
92 # the user told us where it is, great. More likely, though, it's only |
|
93 # in the directory with the library that we're eventually going to |
|
94 # link with. We have no way of knowing what that is, so let's use the |
|
95 # location of this script itself as the default. |
|
96 if test -z "$config_dir"; then |
|
97 if test -r ./klibtool.config; then |
|
98 config_dir=. |
|
99 else |
|
100 dir=`echo $0 | sed 's,/[^/]*$,,'` |
|
101 test -r $dir/klibtool.config && config_dir=$dir |
|
102 fi |
|
103 fi |
|
104 if test -z "$config_dir"; then |
|
105 echo "$0: Cannot find klibtool.config in . or $dir," >&2 |
|
106 echo "$0: and no --config-dir option specified." >&2 |
|
107 exit 1 |
|
108 fi |
|
109 # Read the file. |
|
110 . $config_dir/klibtool.config |
|
111 |
|
112 if test -z "$LIBTOOL_OBJTYPES"; then |
|
113 echo "$0: Impossibly empty LIBTOOL_OBJTYPES!" >&2 |
|
114 echo "$bug_report" >&2 |
|
115 exit 1 |
|
116 fi |
|
117 # Copy the valid object type names from LIBTOOL_OBJTYPES into objtypes. |
|
118 $verbose "$0: checking LIBTOOL_OBJTYPES = $LIBTOOL_OBJTYPES." |
|
119 objtypes= |
|
120 for ot in `echo $LIBTOOL_OBJTYPES | tr : " "`; do |
|
121 case $ot in |
|
122 SHARED) |
|
123 if $shared_support; then |
|
124 objtypes=$objtypes:$ot |
|
125 else |
|
126 echo "$0: Shared libraries not supported on this system." >&2 |
|
127 fi |
|
128 ;; |
|
129 STATIC) |
|
130 objtypes=$objtypes:$ot;; |
|
131 "") true;; # don't worry about empty object types. |
|
132 *) |
|
133 echo "$0: Ignoring unknown libtool object type $objtype." >&2;; |
|
134 esac |
|
135 done |
|
136 # Remove the extra trailing colon from our list-building. |
|
137 objtypes=`echo $objtypes | sed 's/^://'` |
|
138 if test -z $objtypes; then |
|
139 # If they just took the default, we started with STATIC and so |
|
140 # wouldn't be here. |
|
141 echo "$0: No valid object types in $LIBTOOL_OBJTYPES, quitting." >&2 |
|
142 exit 1 |
|
143 fi |
|
144 $verbose "$0: final objtypes = $objtypes." |
|
145 fi |
|
146 |
|
147 |
|
148 # |
|
149 # Do the deed. |
|
150 # |
|
151 # I wish we had subroutines so we could make this readable, but shell |
|
152 # functions aren't portable enough, even nowadays. |
|
153 # |
|
154 $verbose "$0: mode = $mode." |
|
155 case $mode in |
|
156 |
|
157 |
|
158 # configure mode: [HOSTTYPE] |
|
159 configure) |
|
160 # If no config dir specified, use the script location. |
|
161 if test -z "$config_dir"; then |
|
162 if echo $0 | grep / >/dev/null; then |
|
163 config_dir=`echo $0 | sed 's,/[^/]*$,,'` |
|
164 else |
|
165 config_dir=. # $0 is just the script name, no directory part. |
|
166 fi |
|
167 fi |
|
168 config_file=$config_dir/klibtool.config |
|
169 $verbose "$0: writing to config_file = $config_file." |
|
170 |
|
171 # If no specified HOSTTYPE, guess it. |
|
172 if test $# -eq 0; then |
|
173 config_guess=$config_dir/config.guess |
|
174 if test ! -r $config_guess; then |
|
175 echo "$0: config.guess not in $config_dir." >&2 |
|
176 echo "$0: Either specify a host type or get the scripts." >&2 |
|
177 exit 1 |
|
178 fi |
|
179 host_alias=`$config_guess` |
|
180 else |
|
181 test $# -eq 1 \ |
|
182 || echo "$0: Using $1 as host alias, ignoring other arguments ($*)." >&2 |
|
183 host_alias=$1 |
|
184 fi |
|
185 |
|
186 # Convert the original host type to canonical form. |
|
187 config_sub=$config_dir/config.sub |
|
188 if test ! -r $config_sub; then |
|
189 echo "$0: config.sub missing from $config_dir; it's required." >&2 |
|
190 exit 1 |
|
191 fi |
|
192 host_type=`$config_sub $host_alias` |
|
193 if test -z "$host_type"; then |
|
194 echo "$0: $host_alias not a recognizable host type." >&2 |
|
195 exit 1 |
|
196 fi |
|
197 |
|
198 # Finally, we'll be creating something. |
|
199 rm -f $config_file |
|
200 |
|
201 # Define defaults, to be overridden in the system-specific cases. |
|
202 config_vars="LIBTOOL_OBJTYPES shared_support shared_ext libpath_var CC |
|
203 args_STATIC_compile args_SHARED_compile |
|
204 args_STATIC_archive STATIC_ranlib args_SHARED_archive |
|
205 args_SHARED_link |
|
206 SHARED_postinstall" |
|
207 for v in $config_vars; do |
|
208 # Preserve existing value of a couple variables. |
|
209 case $v in |
|
210 LIBTOOL_OBJTYPES|CC) true;; |
|
211 *) eval $v=;; |
|
212 esac |
|
213 done |
|
214 test -z "$LIBTOOL_OBJTYPES" && LIBTOOL_OBJTYPES=STATIC |
|
215 shared_ext=so |
|
216 libpath_var=LD_LIBRARY_PATH |
|
217 STATIC_ranlib=$RANLIB |
|
218 |
|
219 # The compiler. If the user set CC, take that, else use gcc if we |
|
220 # can find it, else use cc. Up to the user to avoid /usr/ucb/cc. |
|
221 if test -z "$CC"; then |
|
222 for dir in `echo $PATH | tr : ' '`; do |
|
223 test -z "$dir" && dir=. |
|
224 if test -f $dir/gcc; then |
|
225 CC=gcc |
|
226 break |
|
227 fi |
|
228 done |
|
229 fi |
|
230 test -z "$CC" && CC=cc |
|
231 # |
|
232 # But the real question is not the name of the command, it's whether |
|
233 # it is GNU C. We only distinguish gcc and system cc. We have to |
|
234 # assume that they use the same compiler at `klibtool compile' time |
|
235 # as we determine here; the whole point is that we don't want to do |
|
236 # this check before compiling every file (for speed). |
|
237 rm -f conftest.c |
|
238 ( |
|
239 echo "#ifdef __GNUC__" |
|
240 echo "yes;" |
|
241 echo "#endif" |
|
242 ) >conftest.c |
|
243 if eval "$CC -E conftest.c" | grep yes >/dev/null 2>&1; then |
|
244 compiler=gcc |
|
245 args_SHARED_compile=-fPIC # should we have an option for -fpic? |
|
246 args_SHARED_archive=-shared |
|
247 else |
|
248 compiler=cc |
|
249 fi |
|
250 rm -f conftest.c |
|
251 |
|
252 # Override defaults for this system. |
|
253 case $host_type in |
|
254 *-*-linux*) |
|
255 shared_support=true |
|
256 SHARED_postinstall='ldconfig $libdir' |
|
257 ;; |
|
258 |
|
259 *-*-solaris2*) |
|
260 shared_support=true |
|
261 if test $compiler = cc; then # /opt/SUNWspro/cc, that is. |
|
262 args_SHARED_compile=-KPIC |
|
263 args_SHARED_archive="-G -z text" # Perhaps should have -h. |
|
264 fi |
|
265 ;; |
|
266 |
|
267 *-*-sunos4*) |
|
268 shared_support=true |
|
269 STATIC_ranlib=ranlib |
|
270 SHARED_postinstall='ldconfig $libdir' |
|
271 if test $compiler = cc; then |
|
272 args_SHARED_compile=-PIC |
|
273 prog_SHARED_archive=ld |
|
274 args_SHARED_archive="-assert pure-text" # gord has -Bstatic? |
|
275 fi |
|
276 ;; |
|
277 |
|
278 *) |
|
279 echo "$0: $host_type not explicitly supported, using defaults." >&2 |
|
280 ;; |
|
281 esac |
|
282 |
|
283 # Output values. |
|
284 for v in $config_vars; do |
|
285 config_line=$v=\'`eval echo '$'$v`\' |
|
286 $verbose "$0: writing config line $config_line." |
|
287 echo $config_line >>$config_file |
|
288 done |
|
289 ;; |
|
290 |
|
291 |
|
292 # compile mode: CC SOURCEFILE [ARG]... |
|
293 compile) |
|
294 compiler=$1; shift # must assume it's what configure found |
|
295 sourcefile=$1 |
|
296 objname=`basename $sourcefile | sed 's/\.[^./]*$//'`.o |
|
297 $verbose "$0: object basename for source file $sourcefile = $objname." |
|
298 # |
|
299 for ot in `echo $objtypes | tr : " "`; do |
|
300 # Snarf arguments for this object type. |
|
301 ot_args=`eval echo '$'args_${ot}_${mode}` |
|
302 $verbose "$0: args_${ot}_${mode} = $ot_args." |
|
303 |
|
304 # Have to output into a subdirectory of current directory (not |
|
305 # source directory, which might be read-only). |
|
306 output_arg="-o $ot/$objname" |
|
307 if test ! -d $ot; then |
|
308 $show mkdir $ot |
|
309 $chicken mkdir $ot |
|
310 fi |
|
311 |
|
312 # Construct and run the cmd. |
|
313 cmd="$compiler ""$@"" $ot_args $output_arg" |
|
314 $show $cmd |
|
315 $chicken $cmd |
|
316 status=$? |
|
317 test $status -eq 0 || break |
|
318 done # end of objtypes loop for compile mode |
|
319 test $status -eq 0 && date >./"`echo $objname | sed 's/o$/lo/'`" |
|
320 exit $status |
|
321 ;; |
|
322 |
|
323 |
|
324 # archive mode |
|
325 archive) |
|
326 cmdname=$1; shift # the archiver |
|
327 for ot in `echo $objtypes | tr : " "`; do |
|
328 libname= |
|
329 args= |
|
330 if test $ot = SHARED; then |
|
331 # Can't generally use ar to make a shared library. |
|
332 old_ar="$cmdname $1" |
|
333 shift |
|
334 ot_args=`eval echo '$'args_SHARED_archive` |
|
335 ot_prog=`eval echo '$'prog_SHARED_archive` |
|
336 test -z "$ot_prog" && ot_prog=$CC |
|
337 cmdname="$ot_prog $ot_args -o" |
|
338 $verbose "$0: replaced $old_ar with $cmdname." |
|
339 fi |
|
340 |
|
341 # Now transform remaining arguments (presumably filenames). |
|
342 for arg in "$@"; do |
|
343 case "$arg" in |
|
344 *.l[ao]) # Remove the `l' from a .la or .lo filename. |
|
345 newarg=`echo $arg | sed 's/l\(.\)$/\1/'` |
|
346 $verbose "$0: transformed arg $arg to $newarg." |
|
347 # First .la file is the output library. |
|
348 if test -z "$libname" && echo $newarg | grep '\.a$'>/dev/null; then |
|
349 if test $ot = SHARED; then |
|
350 $verbose "$0: running $0 version $newarg." |
|
351 verstring=`$0 version $newarg` |
|
352 $verbose "$0: got version $verstring." |
|
353 libname=`echo $newarg | sed 's/\.a$/\.'$shared_ext$verstring/` |
|
354 else |
|
355 libname=$newarg |
|
356 fi |
|
357 if echo $libname | grep / >/dev/null; then |
|
358 lib_dir=`echo $libname | sed 's,/[^/]*$,,'` |
|
359 else |
|
360 lib_dir=. |
|
361 fi |
|
362 lib_basename=`basename $libname` |
|
363 lib_base=`echo $lib_basename | sed 's/[.0-9]*$//'` |
|
364 |
|
365 # We might have to run a command after making the library. |
|
366 post= |
|
367 if test $ot = SHARED; then |
|
368 # If it supports shared libraries, it supports symlinks. |
|
369 # Although this is unnecessary on (e.g.) SunOS, it |
|
370 # doesn't hurt, and it is necessary on (e.g.) Solaris. |
|
371 post="&& ln -s $lib_basename $lib_base" |
|
372 elif test $ot = STATIC; then |
|
373 ranlib=`eval echo '$'${ot}_ranlib` |
|
374 $verbose "${ot}_ranlib = $ranlib." |
|
375 test -n "$ranlib" && post="&& $ranlib $lib_basename" |
|
376 fi |
|
377 |
|
378 $verbose "$0: output library dir = $lib_dir." |
|
379 $verbose "$0: output library basename = $lib_basename." |
|
380 $verbose "$0: output library base = $lib_base." |
|
381 newarg=$lib_basename |
|
382 fi |
|
383 arg=$newarg |
|
384 ;; |
|
385 esac |
|
386 args="$args $arg" |
|
387 done |
|
388 if test -z "$libname"; then |
|
389 # FIXME: should check that the .la file was second arg. |
|
390 echo "$0 archive: .la (libtool archive) argument missing." >&2 |
|
391 exit 1 |
|
392 fi |
|
393 |
|
394 # Remove old archive file because we recommend `ar q', not `r', |
|
395 # and the user can't necessarily know the library name. |
|
396 cmd="cd $lib_dir/$ot && rm -f $lib_base* && $cmdname $args $post" |
|
397 $show $cmd |
|
398 $chicken eval "($cmd)" |
|
399 status=$? |
|
400 test $status -eq 0 || break |
|
401 |
|
402 # If making both objtypes, need original arguments next time through. |
|
403 if test $ot = SHARED; then |
|
404 cmdname=$old_ar |
|
405 else |
|
406 true # Don't think we failed to make the library just because |
|
407 # the last objtype was not SHARED. |
|
408 fi |
|
409 done # end of objtypes loop for archive mode |
|
410 # |
|
411 # Create the .la file we claimed that we would. |
|
412 test $status -eq 0 && date >./"`echo $libname | sed 's/\.[^/]*$/.la/'`" |
|
413 exit $status |
|
414 ;; |
|
415 |
|
416 |
|
417 # link mode |
|
418 link) |
|
419 cmdname=$1; shift # the linker |
|
420 # Do links using the first object type. |
|
421 linktype=`echo $objtypes | sed 's/:.*//'` |
|
422 $verbose "$0: linktype = $linktype." |
|
423 if test -z "$linktype"; then |
|
424 echo "$0: Impossibly empty linktype?!" >&2 |
|
425 exit 1 |
|
426 fi |
|
427 # |
|
428 # Need to know the output name if we generate the wrapper. |
|
429 looking_for_output=false |
|
430 real_output_name= |
|
431 libpath= |
|
432 # |
|
433 for arg in "$@"; do |
|
434 if $looking_for_output; then |
|
435 real_output_name=$arg |
|
436 arg=$real_output_name.exe |
|
437 looking_for_output=false |
|
438 fi |
|
439 case "$arg" in |
|
440 -o) |
|
441 test $linktype = SHARED && looking_for_output=true |
|
442 ;; |
|
443 *.l[ao]) # Find .la files in the linktype subdir |
|
444 # of the given directory, e.g., if the user says |
|
445 # ../foo/libfoo.la, transform into |
|
446 # ../foo/$linktype/libfoo.{a,so...}. We do the same for |
|
447 # libtool archive, although it's not as often necessary. |
|
448 newarg=`echo $arg | sed -e 's,\([^/]*\)$,'$linktype'/\1,' \ |
|
449 -e 's/l\(.\)$/\1/'` |
|
450 if test $linktype = SHARED \ |
|
451 && echo $newarg | grep '\.a$' >/dev/null; then |
|
452 # If shared, transform dir/foo.la into -Ldir -lfoo. |
|
453 dir=`echo $newarg | sed 's,/[^/]*$,,'` |
|
454 lib=`echo $newarg | sed -e 's,.*/\([^/]*\),\1,' \ |
|
455 -e 's/^lib//' -e 's/\.a$//'` |
|
456 newarg="-L$dir -l$lib" |
|
457 # Remember we will need this directory in LD_LIBRARY_PATH. |
|
458 if echo $dir | grep -v '^/' >/dev/null; then |
|
459 dir=`pwd`/$dir |
|
460 fi |
|
461 # Maybe had previous directories. |
|
462 test -n "$libpath" && libpath=$libpath: |
|
463 libpath=$libpath$dir |
|
464 fi |
|
465 $verbose "$0: transformed .la arg $arg to $newarg." |
|
466 arg=$newarg |
|
467 ;; |
|
468 *.lo) # .lo files have no directory stripping or suffix changing. |
|
469 newarg=`echo $arg | sed -e 's,\([^/]*\)$,'$linktype'/\1,' \ |
|
470 -e 's/l\(.\)$/\1/'` |
|
471 $verbose "$0: transformed .lo arg $arg to $newarg." |
|
472 arg=$newarg |
|
473 ;; |
|
474 esac |
|
475 args="$args $arg" |
|
476 done |
|
477 |
|
478 # Set up to generate wrapper shell script if shared. |
|
479 if test $linktype = SHARED; then |
|
480 if $looking_for_output; then |
|
481 echo "$0 link: -o requires an argument." >&2 |
|
482 exit 1 |
|
483 fi |
|
484 if test -z "$real_output_name"; then |
|
485 # If they didn't give -o at all, default to a.out. |
|
486 real_output_name=a.out |
|
487 args="$args -o $real_output_name.exe" |
|
488 fi |
|
489 fi |
|
490 |
|
491 # Do the link. |
|
492 cmd="$cmdname $args" |
|
493 $show $cmd |
|
494 $chicken $cmd |
|
495 |
|
496 status=$? |
|
497 if test $status -eq 0 && test -n "$real_output_name"; then |
|
498 $verbose "$0: creating wrapper $real_output_name." |
|
499 # We created the binary, so create the wrapper script. |
|
500 # Use as short a temporary suffix as we can to minimize the chance |
|
501 # of collisions on deficient systems. |
|
502 rm -f ${real_output_name} ${real_output_name}T |
|
503 ( |
|
504 libpath_var_val='$'$libpath_var |
|
505 echo "#! /bin/sh" |
|
506 echo "# Generated `date` by $0." |
|
507 echo "# Do not install this wrapper script." |
|
508 echo "# It's only here to enable running $real_output_name" |
|
509 echo "# before it's installed. (Use $0 install-progs to install it.)" |
|
510 echo |
|
511 echo "if test -z \"$libpath_var_val\"; then" |
|
512 echo " $libpath_var=\"$libpath\"" |
|
513 echo "else" |
|
514 echo " $libpath_var=\"$libpath:$libpath_var_val\"" |
|
515 echo "fi" |
|
516 echo "export $libpath_var" |
|
517 echo |
|
518 echo "thisdir=\`echo $""0 | sed 's%/[^/]*$%%'\`" |
|
519 echo 'test "x$thisdir" = "x$0" && thisdir=.' |
|
520 echo |
|
521 echo "exec \$thisdir/$real_output_name.exe \"\$@\"" |
|
522 ) >${real_output_name}T |
|
523 chmod +x ${real_output_name}T |
|
524 mv ${real_output_name}T ${real_output_name} |
|
525 fi |
|
526 exit $status |
|
527 ;; |
|
528 |
|
529 |
|
530 # install-lib mode: DIR LIBNAME... |
|
531 install-lib) |
|
532 if test $# -lt 2; then |
|
533 echo "$0 install-lib: Need directory and at least one library." >&2 |
|
534 exit 1 |
|
535 fi |
|
536 libdir=$1; shift |
|
537 if test ! -d $libdir; then |
|
538 echo "$0 install-lib: $1 not a directory." >&2 |
|
539 exit 1 |
|
540 fi |
|
541 for arg in "$@"; do # for each library... |
|
542 # Always having a directory part simplifies the code below. |
|
543 echo $arg | grep / >/dev/null || arg="./$arg" |
|
544 for ot in `echo $objtypes | tr : " "`; do # for each object type... |
|
545 case $ot in |
|
546 SHARED) # needs shared extension and version number. |
|
547 verstring=`$0 version $arg` |
|
548 libname=`echo $arg | sed 's/\.la$/\.'$shared_ext$verstring/` |
|
549 ;; |
|
550 STATIC) # just get rid of the `l'. |
|
551 libname=`echo $arg | sed 's/l\(.\)$/\1/'` |
|
552 ;; |
|
553 *) |
|
554 echo "$0: Impossible object type $ot!" >&2 |
|
555 echo "$bug_report" >&2 |
|
556 exit 1;; |
|
557 esac |
|
558 # Have to insert the object type directory. |
|
559 libname=`echo $libname | sed 's,\(/[^/]*\)$,/'$ot'\1,'` |
|
560 lib_basename=`basename $libname` |
|
561 $verbose "$0: library name = $libname." |
|
562 $verbose "$0: installation name = $libdir/$lib_basename." |
|
563 cmd="${INSTALL_DATA-cp} $libname $libdir/$lib_basename" |
|
564 # |
|
565 if test $ot = SHARED; then |
|
566 # Link libfoo.so to libfoo.so.1.2.3. |
|
567 lib_base=`echo $lib_basename | sed 's/[.0-9]*$//'` |
|
568 $verbose "$0: linking $libdir/$lib_base to $lib_basename" |
|
569 (cd $libdir && ln -s $lib_basename $lib_base) |
|
570 fi |
|
571 # |
|
572 # Run ldconfig, etc. |
|
573 postinstall=`eval echo '$'${ot}_postinstall` |
|
574 test -n "$postinstall" && cmd="$cmd && $postinstall" |
|
575 $show $cmd |
|
576 $chicken eval "$cmd" |
|
577 done |
|
578 done |
|
579 ;; |
|
580 |
|
581 |
|
582 # install-prog mode: DIR PROGNAME... |
|
583 install-prog) |
|
584 if test $# -lt 2; then |
|
585 echo "$0 install-prog: Need directory and at least one program." >&2 |
|
586 exit 1 |
|
587 fi |
|
588 dir=$1; shift |
|
589 if test ! -d $dir; then |
|
590 echo "$0 install-prog: $1 not a directory." >&2 |
|
591 exit 1 |
|
592 fi |
|
593 # The program got linked using the first object type, so |
|
594 # installation of the program will proceed accordingly. |
|
595 linktype=`echo $objtypes | sed 's/:.*//'` |
|
596 $verbose "$0: linktype = $linktype." |
|
597 if test -z "$linktype"; then |
|
598 echo "$0: Impossibly empty linktype?!" >&2 |
|
599 exit 1 |
|
600 fi |
|
601 if test $linktype = SHARED; then |
|
602 # Install the binary, not the wrapper script. |
|
603 suffix=.exe |
|
604 else |
|
605 suffix= |
|
606 fi |
|
607 for arg in "$@"; do # for each program... |
|
608 # FIXME: On SunOS, AIX, and HP-UX, relink to avoid hardwired libdirs. |
|
609 cmd="${INSTALL_PROGRAM-cp} $arg$suffix $dir/$arg" |
|
610 $show $cmd |
|
611 $chicken $cmd |
|
612 done |
|
613 ;; |
|
614 |
|
615 |
|
616 # version mode |
|
617 version) |
|
618 if test $# -ne 1; then |
|
619 echo "$0 version: Exactly one argument needed, not $# ($*)." >&2 |
|
620 exit 1 |
|
621 fi |
|
622 # Strip directory name, `lib' prefix, and any .suffix. |
|
623 dir=`echo $1 | sed 's,/[^/]*$,,'` |
|
624 test "x$dir" = "x$1" && dir=. |
|
625 libname=`basename $1 | sed -e 's,^lib,,' -e s',\..*$,,'` |
|
626 verfile=$dir/klibtool.version |
|
627 if test ! -r $verfile; then |
|
628 echo "$0 version: No file $verfile for $libname version info." >&2 |
|
629 echo "$0 version: Original argument was $1." >&2 |
|
630 exit 1 |
|
631 fi |
|
632 $verbose "$0: dir = $dir, libname = $libname." |
|
633 version=`awk '$1 == "'$libname'" { print "." $2 "." $3 "." $4 }' $verfile` |
|
634 $verbose "$0: version for $libname = $version." |
|
635 echo $version |
|
636 ;; |
|
637 |
|
638 |
|
639 # unknown mode |
|
640 *) |
|
641 echo "$0: Impossible mode \`$mode'!" >&2 |
|
642 echo "$bug_report" >&2 |
|
643 exit 1 |
|
644 ;; |
|
645 esac |