Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / alternatives.mk
blob89b51b199556115c30ac73424813eb289d2a2258
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:
8 # (none)
10 # Package-settable variables:
12 # ALTERNATIVES_SRC
13 # A _single_ file that contains the alternatives provided by the
14 # package.
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:
25 # PKG_ALTERNATIVES
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
38 .endif
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}; \
47 ${ECHO} 'EOF'; \
48 ${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
49 ${ECHO} '${PKG_ALTERNATIVES} -gs register ./+ALTERNATIVES'; \
50 ${ECHO} 'fi'; \
51 ${ECHO} 'fi'; \
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'; \
58 ${ECHO} 'fi'; \
59 ${ECHO} '${RM} -f ./+ALTERNATIVES'; \
60 ${ECHO} 'fi'; \
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
72 .endif
74 .endif # ALTERNATIVES_MK