pkgsrc/mk/alternatives.mk
jperkin 7002b040bb Remove mk/find-prefix.mk and its usage from the mk infrastructure.
The find-prefix infrastructure was required in a pkgviews world where
packages installed from pkgsrc could have different installation
prefixes, and this was a way for a dependency prefix to be determined.

Now that pkgviews has been removed there is no longer any need for the
overhead of this infrastructure.  Instead we use BUILDLINK_PREFIX.pkg
for dependencies pulled in via buildlink, or LOCALBASE/PREFIX where the
dependency is coming from pkgsrc.

Provides a reasonable performance win due to the reduction of `pkg_info
-qp` calls, some of which were redundant anyway as they were duplicating
the same information provided by BUILDLINK_PREFIX.pkg.
2015-11-25 13:05:47 +00:00

72 lines
1.9 KiB
Makefile

# $NetBSD: alternatives.mk,v 1.12 2015/11/25 13:05:47 jperkin Exp $
#
# This Makefile fragment handles the alternatives system, registering a
# package in the database.
#
# User-settable variables:
#
# (none)
#
# Package-settable variables:
#
# ALTERNATIVES_SRC
# A _single_ file that contains the alternatives provided by the
# package.
#
# Default value: The name of the ALTERNATIVES file in the package
# directory, if it exists. Otherwise, nothing.
#
# Each line of the alternatives file contains two filenames, first
# the wrapper and then the alternative provided by the package.
# Both paths are relative to PREFIX.
#
# Variables defined by this file:
#
# PKG_ALTERNATIVES
# The path to the pkg_alternatives command.
#
.if !defined(ALTERNATIVES_MK)
ALTERNATIVES_MK= # defined
_VARGROUPS+= alternatives
_PKG_VARS.alternatives= ALTERNATIVES_SRC
_SYS_VARS.alternatives= PKG_ALTERNATIVES
.if exists(${.CURDIR}/ALTERNATIVES)
ALTERNATIVES_SRC?= ${.CURDIR}/ALTERNATIVES
.endif
ALTERNATIVES_SRC?= # none
.if !empty(ALTERNATIVES_SRC)
${WRKDIR}/.altinstall: ${ALTERNATIVES_SRC}
@{ ${ECHO} 'if ${TEST} $${STAGE} = "POST-INSTALL"; then'; \
${ECHO} '${CAT} >./+ALTERNATIVES <<EOF'; \
${SED} ${FILES_SUBST_SED} <${ALTERNATIVES_SRC}; \
${ECHO} 'EOF'; \
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
${ECHO} '${PKG_ALTERNATIVES} -gs register ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
${ECHO} 'fi'; \
} >${WRKDIR}/.altinstall
${WRKDIR}/.altdeinstall: ${ALTERNATIVES_SRC}
@{ ${ECHO} 'if ${TEST} $${STAGE} = "DEINSTALL"; then'; \
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
${ECHO} '${PKG_ALTERNATIVES} -gs unregister ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
${ECHO} '${RM} -f ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
} >${WRKDIR}/.altdeinstall
PRINT_PLIST_AWK+= /^libdata\/alternatives\// { next; }
PKG_ALTERNATIVES= ${LOCALBASE}/sbin/pkg_alternatives
INSTALL_TEMPLATES+= ${WRKDIR}/.altinstall
DEINSTALL_TEMPLATES+= ${WRKDIR}/.altdeinstall
.endif
.endif # ALTERNATIVES_MK