2006-01-13 00:43:56 +01:00
|
|
|
# /bin/sh
|
|
|
|
#
|
2007-08-02 18:00:33 +02:00
|
|
|
# $NetBSD: shlib-type,v 1.3 2007/08/02 16:00:33 jlam Exp $
|
2006-01-13 00:43:56 +01:00
|
|
|
#
|
|
|
|
# This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
# by Alistair Crooks.
|
|
|
|
#
|
2006-07-21 15:40:27 +02:00
|
|
|
# This script returns the the library format for the platform. If
|
2007-08-02 18:00:33 +02:00
|
|
|
# the library format is "ELF/a.out", then we inspect the specified
|
|
|
|
# path to determine the correct object format (either ELF or a.out).
|
2006-01-13 00:43:56 +01:00
|
|
|
#
|
|
|
|
|
2007-08-02 17:46:33 +02:00
|
|
|
if [ -z "${FILE_CMD}" ]; then
|
|
|
|
FILE_CMD=file
|
|
|
|
fi
|
2006-01-13 00:43:56 +01:00
|
|
|
|
2007-08-02 18:00:33 +02:00
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
echo 1>&2 "usage: shlib-type libformat binpath"
|
2007-08-02 17:46:33 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2006-01-13 00:43:56 +01:00
|
|
|
|
2007-08-02 18:00:33 +02:00
|
|
|
libformat="$1"
|
|
|
|
binpath="$2"
|
|
|
|
|
2006-01-13 00:43:56 +01:00
|
|
|
sotype=none
|
|
|
|
case "$1" in
|
|
|
|
ELF/a.out)
|
2007-08-02 18:00:33 +02:00
|
|
|
if [ -f "$binpath" ]; then
|
|
|
|
output=`${FILE_CMD} $binpath 2>/dev/null`
|
2006-07-21 15:40:27 +02:00
|
|
|
else
|
2007-08-02 17:46:33 +02:00
|
|
|
output=
|
2006-01-13 00:43:56 +01:00
|
|
|
fi
|
2007-08-02 17:46:33 +02:00
|
|
|
case "$output" in
|
|
|
|
*ELF*dynamically*) sotype="ELF" ;;
|
|
|
|
*shared*library*) sotype="a.out" ;;
|
|
|
|
*dynamically*) sotype="a.out" ;;
|
|
|
|
*) sotype="ELF" ;; # guess "ELF"
|
|
|
|
esac
|
2006-01-13 00:43:56 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
sotype="$1"
|
|
|
|
;;
|
|
|
|
esac
|
2007-08-02 17:46:33 +02:00
|
|
|
echo $sotype
|
2006-01-13 00:43:56 +01:00
|
|
|
|
|
|
|
exit 0
|