1 # $NetBSD: alternatives.mk,v 1.10 2007/09/29 15:56:04 rillig Exp $
3 # This Makefile fragment handles the alternatives system, registering a
4 # package in the database.
6 # User-settable variables:
10 # Package-settable variables:
13 # A _single_ file that contains the alternatives provided by the
16 # Default value: The name of the ALTERNATIVES file in the package
17 # directory, if it exists. Otherwise, nothing.
19 # Each line of the alternatives file contains two filenames, first
20 # the wrapper and then the alternative provided by the package.
21 # Both paths are relative to PREFIX.
23 # Variables defined by this file:
26 # The path to the pkg_alternatives command.
29 .if
!defined
(ALTERNATIVES_MK
)
30 ALTERNATIVES_MK
= # defined
32 _VARGROUPS
+= alternatives
33 _PKG_VARS.alternatives
= ALTERNATIVES_SRC
34 _SYS_VARS.alternatives
= PKG_ALTERNATIVES
36 .if exists
(${.CURDIR
}/ALTERNATIVES
)
37 ALTERNATIVES_SRC?
= ${.CURDIR
}/ALTERNATIVES
39 ALTERNATIVES_SRC?
= # none
41 .if
!empty
(ALTERNATIVES_SRC
)
43 ${WRKDIR}/.altinstall
: ${ALTERNATIVES_SRC}
44 @
{ ${ECHO} 'if ${TEST} $${STAGE} = "POST-INSTALL"; then'; \
45 ${ECHO} '${CAT} >./+ALTERNATIVES <<EOF'; \
46 ${SED} ${FILES_SUBST_SED} <${ALTERNATIVES_SRC}; \
48 ${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
49 ${ECHO} '${PKG_ALTERNATIVES} -gs register ./+ALTERNATIVES'; \
52 } >${WRKDIR}/.altinstall
54 ${WRKDIR}/.altdeinstall
: ${ALTERNATIVES_SRC}
55 @
{ ${ECHO} 'if ${TEST} $${STAGE} = "DEINSTALL"; then'; \
56 ${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
57 ${ECHO} '${PKG_ALTERNATIVES} -gs unregister ./+ALTERNATIVES'; \
59 ${ECHO} '${RM} -f ./+ALTERNATIVES'; \
61 } >${WRKDIR}/.altdeinstall
63 PRINT_PLIST_AWK
+= /^libdata\
/alternatives\
// { next
; }
65 EVAL_PREFIX
+= PREFIX.pkg_alternatives
=pkg_alternatives
66 PREFIX.alternatives_DEFAULT
= ${LOCALBASE}
67 PKG_ALTERNATIVES
= ${PREFIX.pkg_alternatives
}/sbin
/pkg_alternatives
69 INSTALL_TEMPLATES
+= ${WRKDIR}/.altinstall
70 DEINSTALL_TEMPLATES
+= ${WRKDIR}/.altdeinstall
74 .
endif # ALTERNATIVES_MK