pkgsrc/mk/scripts/shlib-type
jlam 21129d3f69 Don't bother using environment variables to pass info the shlib-type
shell script.  Just specify everything on the command line.  Also,
since shlib-type is a plain-old shell script with no bells and whistles,
we can safely run it with "sh" and not "${SH}", which is necessary
because "${SH}" isn't defined at this point.
2007-08-02 16:00:33 +00:00

46 lines
886 B
Text
Executable file

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