summaryrefslogtreecommitdiff
path: root/mk/scripts/shlib-type
blob: f6626a85843696f7413c14f38a1212c1ed67b2b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# /bin/sh
#
# $NetBSD: shlib-type,v 1.2 2007/08/02 15:46: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 "pkg_info" (which
# should exist on a pkgsrc system) to determine the correct object
# format (either ELF or a.out).
#

if [ -z "${FILE_CMD}" ]; then
	FILE_CMD=file
fi
if [ -z "${PKG_INFO_CMD}" ]; then
	PKG_INFO_CMD=/usr/sbin/pkg_info
fi

if [ $# -eq 0 ]; then
	echo 1>&2 "usage: shlib-type libformat"
	exit 1
fi

sotype=none
case "$1" in
ELF/a.out)
	if [ -f "${PKG_INFO_CMD}" ]; then
		output=`${FILE_CMD} ${PKG_INFO_CMD} 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