1 # $NetBSD: alternatives.mk,v 1.3 2005/01/25 16:29:16 jmmv Exp $
3 # This Makefile fragment handles the alternatives system, registering a
4 # package in the database.
6 # The ALTERNATIVES_SRC variable contains the path to a file listing the
7 # alternatives provided by the package. It defaults to the ALTERNATIVES
8 # file in the current directory if found. If this variable is empty, no
9 # actions are taken by this file.
12 .if !defined(ALTERNATIVES_MK)
13 ALTERNATIVES_MK= # defined
15 .if !defined(ALTERNATIVES_SRC)
16 . if exists(${.CURDIR}/ALTERNATIVES)
17 ALTERNATIVES_SRC?= ${.CURDIR}/ALTERNATIVES
23 .if !empty(ALTERNATIVES_SRC)
25 ${WRKDIR}/.altinstall: ${ALTERNATIVES_SRC}
26 @{ ${ECHO} 'if ${TEST} $${STAGE} = "POST-INSTALL"; then'; \
27 ${ECHO} '${CAT} >./+ALTERNATIVES <<EOF'; \
28 ${SED} ${FILES_SUBST_SED} <${ALTERNATIVES_SRC}; \
30 ${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
31 ${ECHO} '${PKG_ALTERNATIVES} -gs register ./+ALTERNATIVES'; \
34 } >${WRKDIR}/.altinstall
36 ${WRKDIR}/.altdeinstall: ${ALTERNATIVES_SRC}
37 @{ ${ECHO} 'if ${TEST} $${STAGE} = "DEINSTALL"; then'; \
38 ${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
39 ${ECHO} '${PKG_ALTERNATIVES} -gs unregister ./+ALTERNATIVES'; \
41 ${ECHO} '${RM} -f ./+ALTERNATIVES'; \
43 } >${WRKDIR}/.altdeinstall
45 PRINT_PLIST_AWK+= /^libdata\/alternatives\// { next; }
46 PRINT_PLIST_AWK+= /^@dirrm libdata\/alternatives/ { next; }
48 EVAL_PREFIX+= PREFIX.pkg_alternatives=pkg_alternatives
49 PREFIX.alternatives_DEFAULT= ${LOCALBASE}
50 PKG_ALTERNATIVES= ${PREFIX.pkg_alternatives}/sbin/pkg_alternatives
52 INSTALL_EXTRA_TMPL+= ${WRKDIR}/.altinstall
53 DEINSTALL_EXTRA_TMPL+= ${WRKDIR}/.altdeinstall
58 .endif # ALTERNATIVES_MK