aboutsummaryrefslogtreecommitdiff
path: root/Mk/Uses/emacs.mk
blob: d601390f05692a77d3a647487326987a09464d05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Provide support for ports requiring Emacs.  This includes flavors with proper
# dependencies and useful variables.
#
# Feature:	emacs
# Usage:	USES=emacs or USES=emacs:args
# Valid ARGS:	build, run, noflavors
#
# build		Indicates that Emacs is required at build time.
# run		Indicates that Emacs is required at run time.
# noflavors	Prevents flavors.  This is implied when there is no run
#               dependency on Emacs.
#
# If build and run are omitted from the argument list, Emacs will be added to
# BUILD_DEPENDS and RUN_DEPENDS.  EMACS_NO_DEPENDS can be set to prevent both
# dependencies.
#
# Variables, which can be set in make.conf:
# DEFAULT_VERSIONS+=          The default flavor for Emacs ports (ports with
#                             USES=emacs, but not the Emacs ports themselves)
#                             can be added to DEFAULT_VERSIONS.  For example,
#                             DEFAULT_VERSIONS+= emacs=nox
#                             Valid flavors: full canna nox devel_full devel_nox
#                             Flavors specified on the command line take
#                             precedence.
#
# Variables, which can be set by ports:
# EMACS_FLAVORS_EXCLUDE:      Do NOT build these Emacs flavors.
#                             If EMACS_FLAVORS_EXCLUDE is not defined and
#                               - there is a run dependency on Emacs
#                               - the noflavors argument is not specified
#                             then all valid Emacs flavors are assumed.
#
# EMACS_NO_DEPENDS:           Do NOT add build or run dependencies on Emacs.
#                             This will prevent flavors.
#
# Variables, which can be read by ports:
# EMACS_CMD:                  Emacs command with full path (e.g. /usr/local/bin/emacs-28.2)
# EMACS_FLAVOR:               Used for dependencies (e.g. BUILD_DEPENDS= dash.el${EMACS_PKGNAMESUFFIX}>0:devel/dash@${EMACS_FLAVOR})
# EMACS_LIBDIR:               Emacs Library directory without ${PREFIX} (e.g. share/emacs)
# EMACS_LIBDIR_WITH_VER:      Library directory without ${PREFIX} including version (e.g. share/emacs/28.2)
# EMACS_MAJOR_VER:            Emacs major version (e.g. 28)
# EMACS_PKGNAMESUFFIX:        PKGNAMESUFFIX to distinguish Emacs flavors
# EMACS_SITE_LISPDIR:         Emacs site-lisp directory without ${PREFIX} (e.g. share/emacs/site-lisp)
# EMACS_VER:                  Emacs version (e.g. 28.2)
# EMACS_VERSION_SITE_LISPDIR: Include version (e.g. share/emacs/28.2/site-lisp)
#-------------------------------------------------------------------------------
#
# MAINTAINER:	emacs@FreeBSD.org

.if !defined(_INCLUDE_USES_EMACS_MK)
_INCLUDE_USES_EMACS_MK=	yes

# Make sure that no dependency or some other environment variable
# pollutes the build/run dependency detection
.undef _EMACS_BUILD_DEP
.undef _EMACS_RUN_DEP
.undef _EMACS_NOFLAVORS
_EMACS_ARGS=		${emacs_ARGS:S/,/ /g}
.  if ${_EMACS_ARGS:Mbuild}
_EMACS_BUILD_DEP=	yes
_EMACS_ARGS:=		${_EMACS_ARGS:Nbuild}
.  endif
.  if ${_EMACS_ARGS:Mrun}
_EMACS_RUN_DEP=		yes
_EMACS_ARGS:=		${_EMACS_ARGS:Nrun}
.  endif
.  if ${_EMACS_ARGS:Mnoflavors}
_EMACS_NOFLAVORS=	yes
_EMACS_ARGS:=		${_EMACS_ARGS:Nnoflavors}
.  endif

# If the port does not specify a build or run dependency, and does not define
# EMACS_NO_DEPENDS, assume both dependencies are required.
.  if !defined(_EMACS_BUILD_DEP) && !defined(_EMACS_RUN_DEP) && \
	!defined(EMACS_NO_DEPENDS)
_EMACS_BUILD_DEP=	yes
_EMACS_RUN_DEP=		yes
.  endif

# Only set FLAVORS when...
.  if defined(_EMACS_RUN_DEP) && !defined(_EMACS_NOFLAVORS)
FLAVORS=	full canna nox devel_full devel_nox
# Sort the default to be first
.    if defined(EMACS_DEFAULT)
FLAVORS:=	${EMACS_DEFAULT} ${FLAVORS:N${EMACS_DEFAULT}}
.    endif
.    for flavor in ${EMACS_FLAVORS_EXCLUDE}
FLAVORS:=	${FLAVORS:N${flavor}}
.    endfor
.  endif

# Only set FLAVOR when...
.  if defined(_EMACS_RUN_DEP) && !defined(_EMACS_NOFLAVORS) && empty(FLAVOR)
.    if defined(EMACS_DEFAULT)
FLAVOR=	${EMACS_DEFAULT}
.    else
FLAVOR=	${FLAVORS:[1]}
.    endif # defined(EMACS_DEFAULT)
.  endif # !defined(_EMACS_NOFLAVORS) && defined(_EMACS_RUN_DEP) && empty(FLAVOR)

.  if !empty(FLAVOR)
EMACS_FLAVOR=	${FLAVOR}
.  else
EMACS_FLAVOR=	full
.  endif

.  if ${FLAVOR:Mdevel*}
EMACS_VER=		30.0.50
EMACS_PORTDIR=		editors/emacs-devel
.  else
EMACS_VER=		29.3
EMACS_PORTDIR=		editors/emacs
.  endif

EMACS_MAJOR_VER=	${EMACS_VER:C/\..*//}
EMACS_LIBDIR=		share/emacs
EMACS_LIBDIR_WITH_VER=	share/emacs/${EMACS_VER}
EMACS_PORT_NAME=	emacs${EMACS_MAJOR_VER}

.  if ${EMACS_FLAVOR} == "devel_full"
EMACS_PKGNAMESUFFIX=	-emacs_devel
.  elif ${EMACS_FLAVOR} == "devel_nox"
EMACS_PKGNAMESUFFIX=	-emacs_devel_nox
.  elif ${EMACS_FLAVOR} == "full"
EMACS_PKGNAMESUFFIX=
.  else
EMACS_PKGNAMESUFFIX=	-emacs_${EMACS_FLAVOR}
.  endif

EMACS_CMD=	${PREFIX}/bin/emacs-${EMACS_VER}
EMACS_SITE_LISPDIR=	${EMACS_LIBDIR}/site-lisp
EMACS_VERSION_SITE_LISPDIR=	${EMACS_LIBDIR_WITH_VER}/site-lisp

.  if defined(_EMACS_BUILD_DEP)
BUILD_DEPENDS+=		${EMACS_CMD}:${EMACS_PORTDIR}@${EMACS_FLAVOR:C/devel_//}
.  endif
.  if defined(_EMACS_RUN_DEP)
RUN_DEPENDS+=	${EMACS_CMD}:${EMACS_PORTDIR}@${EMACS_FLAVOR:C/devel_//}
.  endif

MAKE_ARGS+=	EMACS=${EMACS_CMD}
SCRIPTS_ENV+=	EMACS_LIBDIR=${EMACS_LIBDIR} \
		EMACS_VER=${EMACS_VER} \
		EMACS_LIBDIR_WITH_VER=${EMACS_LIBDIR_WITH_VER} \
		EMACS_SITE_LISPDIR=${EMACS_SITE_LISPDIR} \
		EMACS_VERSION_SITE_LISPDIR=${EMACS_VERSION_SITE_LISPDIR}

PLIST_SUB+=	EMACS_LIBDIR=${EMACS_LIBDIR} \
		EMACS_VER=${EMACS_VER} \
		EMACS_LIBDIR_WITH_VER=${EMACS_LIBDIR_WITH_VER} \
		EMACS_SITE_LISPDIR=${EMACS_SITE_LISPDIR} \
		EMACS_VERSION_SITE_LISPDIR=${EMACS_VERSION_SITE_LISPDIR}

.endif # _INCLUDE_USES_EMACS_MK