summaryrefslogtreecommitdiff
path: root/emulators/compat_netbsd
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2007-08-21 22:49:02 +0000
committerjlam <jlam@pkgsrc.org>2007-08-21 22:49:02 +0000
commitffd0fa8226d0808ce1982c1aede01b2328403b8f (patch)
treec963fbe349aa6c3a854fc36e80c1b467ee94113c /emulators/compat_netbsd
parentf7addad279e6d9bddee039abf2c4e73c32086181 (diff)
downloadpkgsrc-ffd0fa8226d0808ce1982c1aede01b2328403b8f.tar.gz
* Support netbsd-* as a valid platform in EMUL_PLATFORMS. Use the
pkgsrc/emulator/compat* and pkgsrc/emulator/netbsd32_compat* packages to provide the necessary shared libraries to run dynamically linked NetBSD binaries from the days of yore. * Add some additional compat* packages for completeness: compat15, compat20, compat30 * Modify the compat* packages so that "compatNM" only provides files that aren't in "NetBSD-N.(M+1)". For example, compat12 only provides files that don't exist in NetBSD-1.3.x, compat13 only provides files that don't exist in NetBSD-1.4.x, etc. As a result, if you are running NetBSD-3.0/alpha and want to run a 1.3 dynamically linked binary, there is an automatic dependency chain that causes the following packages to be installed: compat13, compat14, compat15, compat16, compat20 There are some deviations from this dependency chain on platforms that have changed executable formats, e.g. i386, m68, sparc, etc. However, in general pkgsrc will require that you have the necessary COMPAT_* options in your kernel to match the installed compat* packages. This restriction is an artificial one imposed by pkgsrc, but allows for a single set of distfiles to be used on all versions of NetBSD. * Provide compat* package support for every supported architecture of NetBSD. Verily, it is now possible to run 1.2 binaries on NetBSD-1.5.3/pc532 by installing the compat12 package from pkgsrc. Rejoice, one and all! * The netbsd32_compat* packages mirror the corresponding compat* packages for use by sparc64 and x86_64 to allow running 32-bit binaries with COMPAT_NETBSD32 kernel support. The "extras" packages supply the additional shared libraries from the corresponding release of NetBSD so that the set of files in /emul/netbsd32 will be complete. * pkgsrc/emulators/compat_netbsd contains infrastructure files shared by all of the compat* packages.
Diffstat (limited to 'emulators/compat_netbsd')
-rw-r--r--emulators/compat_netbsd/DEINSTALL9
-rw-r--r--emulators/compat_netbsd/INSTALL.ELF137
-rw-r--r--emulators/compat_netbsd/INSTALL.a.out140
-rw-r--r--emulators/compat_netbsd/INSTALL.emulaout134
-rw-r--r--emulators/compat_netbsd/INSTALL.emulnetbsd32110
-rw-r--r--emulators/compat_netbsd/Makefile.common123
6 files changed, 653 insertions, 0 deletions
diff --git a/emulators/compat_netbsd/DEINSTALL b/emulators/compat_netbsd/DEINSTALL
new file mode 100644
index 00000000000..f0f5e298999
--- /dev/null
+++ b/emulators/compat_netbsd/DEINSTALL
@@ -0,0 +1,9 @@
+# $NetBSD: DEINSTALL,v 1.1 2007/08/21 22:49:24 jlam Exp $
+
+case "${STAGE}" in
+POST-DEINSTALL)
+ # Run any actions that require root privileges.
+ ${TEST} ! -x ./+ROOT_ACTIONS ||
+ ./+ROOT_ACTIONS REMOVE ${PKG_METADATA_DIR} || exit 1
+ ;;
+esac
diff --git a/emulators/compat_netbsd/INSTALL.ELF b/emulators/compat_netbsd/INSTALL.ELF
new file mode 100644
index 00000000000..d15f62cc75b
--- /dev/null
+++ b/emulators/compat_netbsd/INSTALL.ELF
@@ -0,0 +1,137 @@
+# $NetBSD: INSTALL.ELF,v 1.1 2007/08/21 22:49:24 jlam Exp $
+
+# Generate a +ROOT_ACTIONS script that runs certain actions that require
+# superuser privileges.
+#
+case "${STAGE},$1" in
+UNPACK,|UNPACK,+ROOT_ACTIONS)
+ ${CAT} > ./+ROOT_ACTIONS << 'EOF'
+#!@SH@
+#
+# +ROOT_ACTIONS - run actions requiring superuser privileges
+#
+# Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir]
+#
+# This script runs certain actions that require superuser privileges.
+# If such privileges are not available, then simply output a message
+# asking the user to run this script with the appropriate elevated
+# privileges.
+#
+# Lines starting with "# SYMLINK: " are data read by this script that
+# name the source paths and corresponding symlink that is managed by
+# this script. If the symlink path is relative, then it is taken to be
+# relative to ${PKG_PREFIX}. The source path is always unchanged.
+#
+# # SYMLINK: /dev/rcd0a ${EMULSUBDIR}/dev/cdrom
+#
+
+CAT="@CAT@"
+CHMOD="@CHMOD@"
+ECHO="@ECHO@"
+ID="@ID@"
+LN="@LN@"
+PWD_CMD="@PWD_CMD@"
+RM="@RM@"
+SED="@SED@"
+TEST="@TEST@"
+
+SELF=$0
+ACTION=$1
+
+CURDIR=`${PWD_CMD}`
+PKG_METADATA_DIR="${2-${CURDIR}}"
+: ${PKGNAME=${PKG_METADATA_DIR##*/}}
+: ${PKG_PREFIX=@PREFIX@}
+
+ROOT_ACTIONS_COOKIE="./+ROOT_ACTIONS_done"
+EUID=`${ID} -u`
+
+exitcode=0
+case $ACTION,$EUID in
+ADD,0)
+ ${ECHO} "" > ${ROOT_ACTIONS_COOKIE}
+ ${CHMOD} g+w ${ROOT_ACTIONS_COOKIE}
+ ${SED} -n "/^\# SYMLINK: /{s/^\# SYMLINK: //;p;}" ${SELF} |
+ while read src dst; do
+ case $src in
+ "") continue ;;
+ esac
+ case $dst in
+ "") continue ;;
+ [!/]*) dst="${PKG_PREFIX}/$dst" ;;
+ esac
+
+ if ${TEST} ! -f "$dst"; then
+ ${ECHO} "${PKGNAME}: linking $dst -> $src"
+ ${LN} -fs "$src" "$dst"
+ else
+ ${ECHO} "${PKGNAME}: $dst already exists"
+ fi
+ done
+ ;;
+
+REMOVE,0)
+ ${SED} -n "/^\# SYMLINK: /{s/^\# SYMLINK: //;p;}" ${SELF} |
+ while read src dst; do
+ case $src in
+ "") continue ;;
+ esac
+ case $dst in
+ "") continue ;;
+ [!/]*) dst="${PKG_PREFIX}/$dst" ;;
+ esac
+
+ if ${TEST} -h "$dst"; then
+ ${ECHO} "${PKGNAME}: removing $dst"
+ ${RM} -f "$dst"
+ fi
+ done
+ ${RM} -f ${ROOT_ACTIONS_COOKIE}
+ ;;
+
+ADD,*)
+ if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then
+ ${CAT} << EOM
+==============================================================================
+Please run the following command with superuser privileges to complete
+the installation of ${PKGNAME}:
+
+ cd ${PKG_METADATA_DIR} && ${SELF} ADD
+
+==============================================================================
+EOM
+ fi
+ ;;
+
+REMOVE,*)
+ if ${TEST} -f ${ROOT_ACTIONS_COOKIE}; then
+ ${CAT} << EOM
+==============================================================================
+Please run the following command with superuser privileges to begin the
+removal of ${PKGNAME}:
+
+ cd ${PKG_METADATA_DIR} && ${SELF} REMOVE
+
+Then, please run pkg_delete(1) again to complete the removal of this
+package.
+
+==============================================================================
+EOM
+ exitcode=1
+ fi
+ ;;
+esac
+exit $exitcode
+
+EOF
+ ${SED} -n "/^\# SYMLINK: /p" ${SELF} >> ./+ROOT_ACTIONS
+ ${CHMOD} +x ./+ROOT_ACTIONS
+ ;;
+esac
+
+case "${STAGE}" in
+POST-INSTALL)
+ ${TEST} ! -x ./+ROOT_ACTIONS ||
+ ./+ROOT_ACTIONS ADD ${PKG_METADATA_DIR}
+ ;;
+esac
diff --git a/emulators/compat_netbsd/INSTALL.a.out b/emulators/compat_netbsd/INSTALL.a.out
new file mode 100644
index 00000000000..5f425bf2147
--- /dev/null
+++ b/emulators/compat_netbsd/INSTALL.a.out
@@ -0,0 +1,140 @@
+# $NetBSD: INSTALL.a.out,v 1.1 2007/08/21 22:49:25 jlam Exp $
+
+# Generate a +ROOT_ACTIONS script that runs certain actions that require
+# superuser privileges.
+#
+case "${STAGE},$1" in
+UNPACK,|UNPACK,+ROOT_ACTIONS)
+ ${CAT} > ./+ROOT_ACTIONS << 'EOF'
+#!@SH@
+#
+# +ROOT_ACTIONS - run actions requiring superuser privileges
+#
+# Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir]
+#
+# This script runs certain actions that require superuser privileges.
+# If such privileges are not available, then simply output a message
+# asking the user to run this script with the appropriate elevated
+# privileges.
+#
+
+CAT="@CAT@"
+CHMOD="@CHMOD@"
+CP="@CP@"
+ECHO="@ECHO@"
+GREP="@GREP@"
+ID="@ID@"
+PWD_CMD="@PWD_CMD@"
+RM="@RM@"
+TEST="@TEST@"
+TOUCH="@TOUCH@"
+
+SELF=$0
+ACTION=$1
+
+CURDIR=`${PWD_CMD}`
+PKG_METADATA_DIR="${2-${CURDIR}}"
+: ${PKGNAME=${PKG_METADATA_DIR##*/}}
+: ${PKG_PREFIX=@PREFIX@}
+
+EMULDIR="${PKG_PREFIX}/@EMULSUBDIR@"
+OPSYS_EMULDIR="@OPSYS_EMULDIR@"
+
+ROOT_ACTIONS_COOKIE="./+ROOT_ACTIONS_done"
+EUID=`${ID} -u`
+
+exitcode=0
+case $ACTION,$EUID in
+ADD,0)
+ ${ECHO} "" > ${ROOT_ACTIONS_COOKIE}
+ ${CHMOD} g+w ${ROOT_ACTIONS_COOKIE}
+ ${SED} -n "/^\# LDCONFIG: /{s/^\# LDCONFIG: //;p;}" ${SELF} |
+ while read dir; do
+ case $dir in
+ /*) continue ;;
+ *) dir="${PKG_PREFIX}/$dir" ;;
+ esac
+ ${TEST} -d "$dir" || continue
+
+ ldsoconf="/etc/ld.so.conf"
+ ${TEST} -f "$ldsoconf" || continue
+ if ${GREP} "^$dir" $ldsoconf >/dev/null; then
+ :
+ else
+ ${ECHO} "${PKGNAME}: adding $dir to $ldsoconf"
+ ${TOUCH} $ldsoconf
+ ${CP} $ldsoconf $ldsoconf.pkgsrc."$$"
+ { ${CAT} $ldsoconf.pkgsrc."$$"; ${ECHO} "$dir"; } > $ldsoconf
+ ${RM} $ldsoconf.pkgsrc."$$"
+ fi
+ done
+ ${ECHO} "${PKGNAME}: creating a.out runtime link editor directory cache."
+ @LDCONFIG_ADD_CMD@
+ ;;
+
+ADD,*)
+ if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then
+ ${CAT} << EOM
+==============================================================================
+Please run the following command with superuser privileges to complete
+the installation of ${PKGNAME}:
+
+ cd ${PKG_METADATA_DIR} && ${SELF} ADD
+
+==============================================================================
+EOM
+ fi
+ ;;
+
+REMOVE,0)
+ ${SED} -n "/^\# LDCONFIG: /{s/^\# LDCONFIG: //;p;}" ${SELF} |
+ { while read dir; do
+ case $dir in
+ /*) continue ;;
+ *) dir="${PKG_PREFIX}/$dir" ;;
+ esac
+ ${TEST} -d "$dir" || continue
+
+ ldsoconf="/etc/ld.so.conf"
+ ${TEST} -f "$ldsoconf" || continue
+ if ${GREP} "^$dir" $ldsoconf >/dev/null; then
+ case "$printed_header" in
+ yes) ;;
+ *) printed_header=yes
+ ${ECHO} "==========================================================================="
+ ${ECHO} "The following lines can be removed from $ldsoconf:"
+ ${ECHO} ""
+ ;;
+ esac
+ ${ECHO} " $dir"
+ fi
+ done
+ case "$printed_header" in
+ yes) ${ECHO} ""
+ ${ECHO} "==========================================================================="
+ exit 1
+ ;;
+ esac; }
+ ${RM} -f ${ROOT_ACTIONS_COOKIE}
+ ;;
+esac
+exit $exitcode
+
+EOF
+ ${CHMOD} +x ./+ROOT_ACTIONS
+ ;;
+esac
+
+# LDCONFIG: @EMULSUBDIRSLASH@usr/X11R6/lib
+# LDCONFIG: @EMULSUBDIRSLASH@usr/lib
+
+EMULDIR="${PKG_PREFIX}/@EMULSUBDIR@"
+OPSYS_EMULDIR="@OPSYS_EMULDIR@"
+
+case "${STAGE}" in
+POST-INSTALL)
+ # Run any actions that require root privileges.
+ ${TEST} ! -x ./+ROOT_ACTIONS ||
+ ./+ROOT_ACTIONS ADD ${PKG_METADATA_DIR}
+ ;;
+esac
diff --git a/emulators/compat_netbsd/INSTALL.emulaout b/emulators/compat_netbsd/INSTALL.emulaout
new file mode 100644
index 00000000000..3cde42f75b5
--- /dev/null
+++ b/emulators/compat_netbsd/INSTALL.emulaout
@@ -0,0 +1,134 @@
+# $NetBSD: INSTALL.emulaout,v 1.1 2007/08/21 22:49:25 jlam Exp $
+
+# Generate a +ROOT_ACTIONS script that runs certain actions that require
+# superuser privileges.
+#
+case "${STAGE},$1" in
+UNPACK,|UNPACK,+ROOT_ACTIONS)
+ ${CAT} > ./+ROOT_ACTIONS << 'EOF'
+#!@SH@
+#
+# +ROOT_ACTIONS - run actions requiring superuser privileges
+#
+# Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir]
+#
+# This script runs certain actions that require superuser privileges.
+# If such privileges are not available, then simply output a message
+# asking the user to run this script with the appropriate elevated
+# privileges.
+#
+
+CAT="@CAT@"
+CHMOD="@CHMOD@"
+CP="@CP@"
+DIRNAME="@DIRNAME@"
+ECHO="@ECHO@"
+ID="@ID@"
+LN="@LN@"
+MKDIR="@MKDIR@"
+PWD_CMD="@PWD_CMD@"
+RM="@RM@"
+SH="@SH@"
+TEST="@TEST@"
+
+SELF=$0
+ACTION=$1
+
+CURDIR=`${PWD_CMD}`
+PKG_METADATA_DIR="${2-${CURDIR}}"
+: ${PKGNAME=${PKG_METADATA_DIR##*/}}
+: ${PKG_PREFIX=@PREFIX@}
+
+EMULDIR="${PKG_PREFIX}/@EMULSUBDIR@"
+OPSYS_EMULDIR="@OPSYS_EMULDIR@"
+
+ROOT_ACTIONS_COOKIE="./+ROOT_ACTIONS_done"
+EUID=`${ID} -u`
+
+exitcode=0
+case $ACTION,$EUID in
+ADD,0)
+ ${ECHO} "" > ${ROOT_ACTIONS_COOKIE}
+ ${CHMOD} g+w ${ROOT_ACTIONS_COOKIE}
+
+ # Create the appropriate symlink so that the kernel will
+ # find the installed files.
+ #
+ OPSYS_EMULDIR_PWD=`cd ${OPSYS_EMULDIR} 2>/dev/null && ${PWD_CMD}`
+ EMULDIR_PWD=`cd ${EMULDIR} 2>/dev/null && ${PWD_CMD}`
+
+ if ${TEST} "${OPSYS_EMULDIR_PWD}" != "${EMULDIR_PWD}"; then
+ if ${TEST} -e ${OPSYS_EMULDIR} -o -L ${OPSYS_EMULDIR}; then
+ ${CAT} << EOM
+==============================================================================
+The following symbolic link must be created for ${PKGNAME}
+to work properly:
+
+ ${EMULDIR} -> ${OPSYS_EMULDIR}
+
+==============================================================================
+EOM
+ else
+ ${ECHO} "${PKGNAME}: creating symlink ${EMULDIR} -> ${OPSYS_EMULDIR}"
+ ( ${MKDIR} -p `${DIRNAME} ${OPSYS_EMULDIR}` &&
+ ${LN} -fs ${EMULDIR} ${OPSYS_EMULDIR} ) || ${TRUE}
+ fi
+ fi
+ if ${TEST} -d ${OPSYS_EMULDIR}; then
+ ${ECHO} "${PKGNAME}: creating a.out runtime link editor directory cache."
+ @LDCONFIG_ADD_CMD@
+ fi
+ ;;
+
+REMOVE,0)
+ if ${TEST} -d ${OPSYS_EMULDIR}; then
+ ${ECHO} "${PKGNAME}: creating a.out runtime link editor directory cache."
+ @LDCONFIG_REMOVE_CMD@
+ fi
+ ${RM} -f ${ROOT_ACTIONS_COOKIE}
+ ;;
+
+ADD,*)
+ if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then
+ ${CAT} << EOM
+==============================================================================
+Please run the following command with superuser privileges to complete
+the installation of ${PKGNAME}:
+
+ cd ${PKG_METADATA_DIR} && ${SELF} ADD
+
+==============================================================================
+EOM
+ fi
+ ;;
+
+REMOVE,*)
+ if ${TEST} -d ${OPSYS_EMULDIR}; then
+ ${CAT} << EOM
+==============================================================================
+Please run the following command with superuser privileges to rebuild
+the a.out runtime link editor directory cache after the removal of
+${PKGNAME}:
+
+ @LDCONFIG_REMOVE_CMD@
+
+==============================================================================
+EOM
+ fi
+ ${RM} -f ${ROOT_ACTIONS_COOKIE}
+ ;;
+esac
+exit $exitcode
+
+EOF
+ ${CHMOD} +x ./+ROOT_ACTIONS
+ ;;
+esac
+
+case "${STAGE}" in
+POST-INSTALL)
+ # Run any actions that require root privileges.
+ ${TEST} ! -x ./+ROOT_ACTIONS ||
+ ./+ROOT_ACTIONS ADD ${PKG_METADATA_DIR}
+ ;;
+esac
diff --git a/emulators/compat_netbsd/INSTALL.emulnetbsd32 b/emulators/compat_netbsd/INSTALL.emulnetbsd32
new file mode 100644
index 00000000000..65af65d5dab
--- /dev/null
+++ b/emulators/compat_netbsd/INSTALL.emulnetbsd32
@@ -0,0 +1,110 @@
+# $NetBSD: INSTALL.emulnetbsd32,v 1.1 2007/08/21 22:49:25 jlam Exp $
+
+# Generate a +ROOT_ACTIONS script that runs certain actions that require
+# superuser privileges.
+#
+case "${STAGE},$1" in
+UNPACK,|UNPACK,+ROOT_ACTIONS)
+ ${CAT} > ./+ROOT_ACTIONS << 'EOF'
+#!@SH@
+#
+# +ROOT_ACTIONS - run actions requiring superuser privileges
+#
+# Usage: ./+ROOT_ACTIONS ADD|REMOVE [metadatadir]
+#
+# This script runs certain actions that require superuser privileges.
+# If such privileges are not available, then simply output a message
+# asking the user to run this script with the appropriate elevated
+# privileges.
+#
+
+CAT="@CAT@"
+CHMOD="@CHMOD@"
+CP="@CP@"
+DIRNAME="@DIRNAME@"
+ECHO="@ECHO@"
+ID="@ID@"
+LN="@LN@"
+MKDIR="@MKDIR@"
+PWD_CMD="@PWD_CMD@"
+RM="@RM@"
+SH="@SH@"
+TEST="@TEST@"
+
+SELF=$0
+ACTION=$1
+
+CURDIR=`${PWD_CMD}`
+PKG_METADATA_DIR="${2-${CURDIR}}"
+: ${PKGNAME=${PKG_METADATA_DIR##*/}}
+: ${PKG_PREFIX=@PREFIX@}
+
+EMULDIR="${PKG_PREFIX}/@EMULSUBDIR@"
+OPSYS_EMULDIR="@OPSYS_EMULDIR@"
+
+ROOT_ACTIONS_COOKIE="./+ROOT_ACTIONS_done"
+EUID=`${ID} -u`
+
+exitcode=0
+case $ACTION,$EUID in
+ADD,0)
+ ${ECHO} "" > ${ROOT_ACTIONS_COOKIE}
+ ${CHMOD} g+w ${ROOT_ACTIONS_COOKIE}
+
+ # Create the appropriate symlink so that the kernel will
+ # find the installed files.
+ #
+ OPSYS_EMULDIR_PWD=`cd ${OPSYS_EMULDIR} 2>/dev/null && ${PWD_CMD}`
+ EMULDIR_PWD=`cd ${EMULDIR} 2>/dev/null && ${PWD_CMD}`
+
+ if ${TEST} "${OPSYS_EMULDIR_PWD}" != "${EMULDIR_PWD}"; then
+ if ${TEST} -e ${OPSYS_EMULDIR} -o -L ${OPSYS_EMULDIR}; then
+ ${CAT} << EOM
+==============================================================================
+The following symbolic link must be created for ${PKGNAME}
+to work properly:
+
+ ${EMULDIR} -> ${OPSYS_EMULDIR}
+
+==============================================================================
+EOM
+ else
+ ${ECHO} "${PKGNAME}: creating symlink ${EMULDIR} -> ${OPSYS_EMULDIR}"
+ ( ${MKDIR} -p `${DIRNAME} ${OPSYS_EMULDIR}` &&
+ ${LN} -fs ${EMULDIR} ${OPSYS_EMULDIR} ) || ${TRUE}
+ fi
+ fi
+ ;;
+
+ADD,*)
+ if ${TEST} ! -f ${ROOT_ACTIONS_COOKIE}; then
+ ${CAT} << EOM
+==============================================================================
+Please run the following command with superuser privileges to complete
+the installation of ${PKGNAME}:
+
+ cd ${PKG_METADATA_DIR} && ${SELF} ADD
+
+==============================================================================
+EOM
+ fi
+ ;;
+
+REMOVE,*)
+ ${RM} -f ${ROOT_ACTIONS_COOKIE}
+ ;;
+esac
+exit $exitcode
+
+EOF
+ ${CHMOD} +x ./+ROOT_ACTIONS
+ ;;
+esac
+
+case "${STAGE}" in
+POST-INSTALL)
+ # Run any actions that require root privileges.
+ ${TEST} ! -x ./+ROOT_ACTIONS ||
+ ./+ROOT_ACTIONS ADD ${PKG_METADATA_DIR}
+ ;;
+esac
diff --git a/emulators/compat_netbsd/Makefile.common b/emulators/compat_netbsd/Makefile.common
new file mode 100644
index 00000000000..9ca372db860
--- /dev/null
+++ b/emulators/compat_netbsd/Makefile.common
@@ -0,0 +1,123 @@
+# $NetBSD: Makefile.common,v 1.1 2007/08/21 22:49:25 jlam Exp $
+#
+# Common infrastructure for NetBSD compat* packages.
+#
+# This file should be included after EMUL_PLATFORMS and NETBSD_VERSION are
+# defined and before EMUL_PLATFORM is used.
+#
+
+PKGNAME= ${DISTNAME:S/-${EMUL_ARCH}-/-/}
+CATEGORIES= emulators
+MASTER_SITES= ${MASTER_SITE_LOCAL}
+EXTRACT_SUFX= .tar.bz2
+
+MAINTAINER= pkgsrc-users@NetBSD.org
+
+NO_SRC_ON_FTP= Already in MASTER_SITE_LOCAL
+
+NETBSD_PKG= yes
+NETBSD_VERSION_REQD= ${NETBSD_VERSION}
+
+.include "../../mk/bsd.prefs.mk"
+
+.if defined(NETBSD_COMPAT32) && defined(ACCEPTABLE_NETBSD)
+ONLY_FOR_PLATFORM+= ${ACCEPTABLE_NETBSD:S/$/-sparc64/}
+ONLY_FOR_PLATFORM+= ${ACCEPTABLE_NETBSD:S/$/-x86_64/}
+.endif
+
+NETBSD_PKGSRCDIR?= ${.CURDIR}/../${.CURDIR:T:S/^netbsd32_//}
+FILESDIR= ${NETBSD_PKGSRCDIR}/files
+PATCHDIR= ${NETBSD_PKGSRCDIR}/patches
+PKGDIR= ${NETBSD_PKGSRCDIR}
+
+.if ((${EMUL_ARCH} == "i386") && (${MACHINE_ARCH} == "x86_64")) || \
+ ((${EMUL_ARCH} == "sparc") && (${MACHINE_ARCH} == "sparc64"))
+PKGNAME:= ${PKGNAME:S/^/netbsd32_/}
+COMMENT:= ${COMMENT:S/NetBSD/NetBSD 32-bit/}
+NETBSD_BASE= netbsd32_
+.else
+NETBSD_BASE= # empty
+.endif
+
+BUILD_DIRS= # empty
+MAKE_DIRS+= ${EMULDIR}
+ELF_SYMLINKS_DATA= ${WRKDIR}/.symlinks-data
+
+#
+# PLISTs are composed from the following bits, in order:
+#
+# PLIST.${EMUL_ARCH} e.g. PLIST.alpha
+# PLIST.${EMUL_EXEC_FMT} e.g. PLIST.ELF
+# PLIST e.g. PLIST
+#
+.if exists(${PKGDIR}/PLIST.${EMUL_ARCH})
+PLIST_SRC+= ${PKGDIR}/PLIST.${EMUL_ARCH}
+.endif
+.if exists(${PKGDIR}/PLIST.${EMUL_EXEC_FMT})
+PLIST_SRC+= ${PKGDIR}/PLIST.${EMUL_EXEC_FMT}
+.endif
+.if exists(${PKGDIR}/PLIST)
+PLIST_SRC+= ${PKGDIR}/PLIST
+.endif
+
+#
+# Different combinations of the native executable format and the emulated
+# executable format require different ways of making the installed shared
+# libraries useful after installation.
+#
+# native emul action
+# ----- ---- ------
+# a.out a.out append to ld.so.conf and run ldconfig
+# ELF a.out run ldconfig
+# ELF ELF create symlinks to shlibs into base system
+# ELF64 ELF32 nothing
+#
+.if (${NATIVE_EXEC_FMT} == "a.out") && (${EMUL_EXEC_FMT} == "a.out")
+INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.a.out
+
+.elif (${NATIVE_EXEC_FMT} == "ELF") && (${EMUL_EXEC_FMT} == "a.out")
+INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.emulaout
+
+.elif defined(NETBSD_COMPAT32)
+INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.emulnetbsd32
+
+.else # (${NATIVE_EXEC_FMT} == "ELF") && (${EMUL_EXEC_FMT} == "ELF")
+INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.ELF
+INSTALL_TEMPLATES+= ${ELF_SYMLINKS_DATA}
+post-build: symlinks-data
+.endif
+
+DEINSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/DEINSTALL
+
+#
+# For ELF platforms, the INSTALL.ELF script needs SYMLINK data lines to
+# tell it which shared libraries need to be symlinked to where. Generate
+# this information from the PLIST.
+#
+.PHONY: symlinks-data
+symlinks-data: ${ELF_SYMLINKS_DATA}
+${ELF_SYMLINKS_DATA}: plist
+ ${RUN} ${CAT} ${PLIST} | ${AWK} \
+ 'BEGIN { print "#" } END { print "#" } /^@/ { next } \
+ { src = $$0; dst = src; sub("^${EMULSUBDIRSLASH}", "/", dst); \
+ print "# SYMLINK: " src " " dst }' > ${.TARGET}
+
+#
+# The compat* packages have a very strict package layout:
+#
+# ${WRKSRC}/lib
+# ${WRKSRC}/libexec
+# ${WRKSRC}/usr
+#
+# Each of these directories, if they exist, are copied directly into
+# ${EMULDIR}.
+#
+.PHONY: compat-install
+do-install: compat-install
+compat-install:
+ ${INSTALL_DATA_DIR} ${PREFIX}/${EMULSUBDIR}
+ cd ${WRKSRC} && for dir in lib libexec usr; do \
+ if ${TEST} -d "$$dir"; then \
+ ${PAX} -rw "$$dir" ${PREFIX}/${EMULSUBDIR}; \
+ fi; \
+ done