summaryrefslogtreecommitdiff
path: root/mk/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'mk/scripts')
-rwxr-xr-xmk/scripts/shlib-type51
1 files changed, 51 insertions, 0 deletions
diff --git a/mk/scripts/shlib-type b/mk/scripts/shlib-type
new file mode 100755
index 00000000000..5a42b58f94e
--- /dev/null
+++ b/mk/scripts/shlib-type
@@ -0,0 +1,51 @@
+# /bin/sh
+#
+# $NetBSD: shlib-type,v 1.1 2007/07/18 18:01:03 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).
+#
+
+: ${ECHO=echo}
+: ${FILE_CMD=file}
+: ${TEST=test}
+: ${PKG_INFO_CMD=/usr/sbin/pkg_info}
+
+self="${0##*/}"
+
+usage() {
+ ${ECHO} 1>&2 "usage: $self libformat"
+}
+
+${TEST} $# -gt 0 || { usage; exit 1; }
+
+sotype=none
+case "$1" in
+ELF/a.out)
+ case "${PKG_INFO_CMD}" in
+ /*) ;;
+ *) PKG_INFO_CMD="/usr/sbin/pkg_info"
+ esac
+ if ${TEST} -f ${PKG_INFO_CMD}; then
+ case `${FILE_CMD} ${PKG_INFO_CMD}` in
+ *ELF*dynamically*) sotype="ELF" ;;
+ *shared*library*) sotype="a.out" ;;
+ *dynamically*) sotype="a.out" ;;
+ esac
+ else
+ # "pkg_info" is missing so just guess "ELF.
+ sotype="ELF"
+ fi
+ ;;
+*)
+ sotype="$1"
+ ;;
+esac
+${ECHO} $sotype
+
+exit 0