Lines 5-20
Link Here
|
5 |
# MAINTAINER: ports@FreeBSD.org |
5 |
# MAINTAINER: ports@FreeBSD.org |
6 |
# Usage: |
6 |
# Usage: |
7 |
# |
7 |
# |
8 |
# USES+= lua[:version] |
8 |
# USES+= lua[:options,...] |
|
|
9 |
# |
10 |
# Options: |
11 |
# |
12 |
# NN (e.g. 52) - specify an allowed Lua version (can use multiple times) |
13 |
# NN+ (e.g. 52+) - specify a minimum Lua version (discouraged) |
14 |
# -NN (e.g. -53) - specify a maximum allowed version |
15 |
# NN-NN (e.g. 51-53) - specify a range of allowed versions |
16 |
# |
17 |
# flavors define FLAVOR / FLAVORS as luaNN from the allowed versions |
18 |
# |
19 |
# noflavors don't use flavors |
20 |
# |
21 |
# module (implies flavors) specifies that the port is a Lua module |
22 |
# (i.e. that it installes files in MODLIBDIR etc.) |
23 |
# |
24 |
# build add dependency to BUILD_DEPENDS instead of LIB_DEPENDS |
25 |
# run add dependency to RUN_DEPENDS instead of LIB_DEPENDS |
26 |
# |
27 |
# env define only the LUA_* vars and add them to PLIST_SUB and |
28 |
# MAKE_ENV, do not add dependencies or other global state |
29 |
# |
30 |
# core for building Lua itself |
31 |
# |
32 |
# If more than one version is allowed, then the LUA_DEFAULT version |
33 |
# (as set in DEFAULT_VERSIONS) is chosen if it is allowed, otherwise |
34 |
# the highest allowed version is chosen. But if "flavors" was requested, |
35 |
# and FLAVOR is set, we use that version. |
36 |
# |
37 |
# LUA_FLAVOR is defined to the desired flavor whether or not "flavors" was |
38 |
# selected; ports should use this to specify the flavor of dependencies |
39 |
# which are Lua modules or otherwise Lua-flavored. |
40 |
# |
41 |
# It's not generally expected that applications that embed Lua, or apps |
42 |
# written in Lua, would use USES=lua:flavors. Given that Lua is lightweight |
43 |
# and does not carry around a whole lot of module ecosystem with it, it is |
44 |
# best that application ports simply specify the Lua version or range of |
45 |
# versions that they support, and let the default one or the latest one be |
46 |
# used. However, they should still use LUA_FLAVOR as needed when specifying |
47 |
# dependencies. |
9 |
# |
48 |
# |
10 |
.if !defined(_INCLUDE_USES_LUA_MK) |
49 |
.if !defined(_INCLUDE_USES_LUA_MK) |
11 |
_INCLUDE_USES_LUA_MK= yes |
50 |
_INCLUDE_USES_LUA_MK= yes |
12 |
|
51 |
|
13 |
# When adding a version, please keep the comment in |
52 |
# When adding a version, please keep the comment in |
14 |
# Mk/bsd.default-versions.mk in sync. |
53 |
# Mk/bsd.default-versions.mk in sync. |
15 |
_LUA_VALID_VERSIONS= 53 52 51 |
54 |
_LUA_VALID_VERSIONS:= 53 52 51 |
|
|
55 |
.if defined(_LUA_EXTRA_VER) |
56 |
_LUA_VALID_VERSIONS+= ${_LUA_EXTRA_VER} |
57 |
.endif |
58 |
|
59 |
_LUA_DEFAULT_VERSION:= ${LUA_DEFAULT:S/.//} |
60 |
|
61 |
# args |
62 |
_LUA_ARG_FLAVORS:= |
63 |
_LUA_ARG_MODULE:= |
64 |
_LUA_ARG_ENV:= |
65 |
_LUA_ARG_CORE:= |
66 |
.if ${lua_ARGS:Mmodule} |
67 |
_LUA_ARG_FLAVORS:=yes |
68 |
_LUA_ARG_MODULE:=yes |
69 |
.endif |
70 |
.if ${lua_ARGS:Mflavors} |
71 |
_LUA_ARG_FLAVORS:=yes |
72 |
.endif |
73 |
.if ${lua_ARGS:Mnoflavors} |
74 |
_LUA_ARG_FLAVORS:= |
75 |
.endif |
76 |
.if ${lua_ARGS:Menv} |
77 |
_LUA_ARG_ENV:=yes |
78 |
.endif |
79 |
.if ${lua_ARGS:Mcore} |
80 |
_LUA_ARG_CORE:=yes |
81 |
_LUA_ARG_ENV:=yes |
82 |
_LUA_ARG_FLAVORS:= |
83 |
_LUA_ARG_MODULE:= |
84 |
.endif |
85 |
|
86 |
# core is for building Lua itself, so it overrides all version checks |
87 |
.if ${_LUA_ARG_CORE} |
88 |
|
89 |
_LUA_WANTED_VERSION:=${lua_ARGS:M[1-9][0-9]:[1]} |
90 |
|
91 |
. if ${lua_ARGS:M[1-9][0-9]:[#]} != 1 |
92 |
IGNORE= USES=lua:core must also specify exactly one version number |
93 |
# set to avoid spurious errors below |
94 |
_LUA_WANTED_VERSION:=${_LUA_DEFAULT_VERSION} |
95 |
. endif |
96 |
|
97 |
_LUA_VALID_VERSIONS:=${_LUA_WANTED_VERSION} |
98 |
_LUA_WANTED_VERSIONS:=${_LUA_WANTED_VERSION} |
99 |
_LUA_DEFAULT_VERSION:=${_LUA_WANTED_VERSION} |
100 |
|
101 |
.endif # _LUA_ARG_CORE |
16 |
|
102 |
|
17 |
_LUA_DEFAULT_VERSION= ${LUA_DEFAULT:S/.//} |
|
|
18 |
.if ! ${_LUA_VALID_VERSIONS:M${_LUA_DEFAULT_VERSION}} |
103 |
.if ! ${_LUA_VALID_VERSIONS:M${_LUA_DEFAULT_VERSION}} |
19 |
IGNORE= Invalid lua version ${LUA_DEFAULT} |
104 |
IGNORE= Invalid lua version ${LUA_DEFAULT} |
20 |
.endif |
105 |
.endif |
Lines 22-110
IGNORE= Invalid lua version ${LUA_DEFAULT}
Link Here
|
22 |
# |
107 |
# |
23 |
# Parse a ver+ argument |
108 |
# Parse a ver+ argument |
24 |
# |
109 |
# |
25 |
.if ${lua_ARGS:M*+} |
110 |
.if ${lua_ARGS:M??+} |
26 |
_LUA_MIN_VERSION:= ${lua_ARGS:M*+:S/+//} |
111 |
_LUA_MIN_VERSION:= ${lua_ARGS:M??+:S/+//} |
|
|
112 |
_LUA_MAX_VERSION:= 99 |
113 |
.endif |
114 |
|
27 |
# |
115 |
# |
28 |
# Resolve minimum versions (ver+). Append anything greater or equal than the |
116 |
# Parse a -ver argument |
29 |
# specified minimum version to the list of wanted versions. |
|
|
30 |
# |
117 |
# |
31 |
. for _v in ${_LUA_VALID_VERSIONS} |
118 |
.if ${lua_ARGS:M-??} |
32 |
. if ${_LUA_MIN_VERSION} <= ${_v} |
119 |
_LUA_MAX_VERSION:= ${lua_ARGS:M-??:S/-//} |
|
|
120 |
_LUA_MIN_VERSION:= 0 |
121 |
.endif |
122 |
|
123 |
# |
124 |
# Parse a ver-ver argument |
125 |
# |
126 |
.if ${lua_ARGS:M??-??} |
127 |
_LUA_MIN_VERSION:= ${lua_ARGS:M??-??:C/-.*//} |
128 |
_LUA_MAX_VERSION:= ${lua_ARGS:M??-??:C/.*-//} |
129 |
.endif |
130 |
|
131 |
# |
132 |
# Parse one or more ver arguments |
133 |
# |
134 |
.if ${lua_ARGS:M[1-9][0-9]} |
135 |
. for _v in ${lua_ARGS:M[1-9][0-9]} |
136 |
. if ${_LUA_VALID_VERSIONS:M${_v}} |
33 |
_LUA_WANTED_VERSIONS+=${_v} |
137 |
_LUA_WANTED_VERSIONS+=${_v} |
34 |
. endif |
138 |
. endif |
35 |
. endfor |
139 |
. endfor |
|
|
140 |
. if empty(_LUA_WANTED_VERSIONS) |
141 |
IGNORE= USES=lua:nn did not find any valid version number |
142 |
. endif |
36 |
.endif |
143 |
.endif |
37 |
|
144 |
|
38 |
# |
145 |
# |
39 |
# Parse one or more ver arguments |
146 |
# Resolve version ranges. Append anything within the range to the list of |
|
|
147 |
# wanted versions. |
40 |
# |
148 |
# |
41 |
.if ${lua_ARGS:M5[1-3]} |
149 |
.if defined(_LUA_MIN_VERSION) && defined(_LUA_MAX_VERSION) |
42 |
_LUA_WANTED_VERSIONS:= ${lua_ARGS:M5[1-3]} |
150 |
. for _v in ${_LUA_VALID_VERSIONS} |
|
|
151 |
. if ${_LUA_MIN_VERSION} <= ${_v} && ${_LUA_MAX_VERSION} >= ${_v} |
152 |
_LUA_WANTED_VERSIONS+=${_v} |
153 |
. endif |
154 |
. endfor |
155 |
. if empty(_LUA_WANTED_VERSIONS) |
156 |
IGNORE= USES=lua:xx-yy did not find any valid version |
157 |
. endif |
43 |
.endif |
158 |
.endif |
44 |
|
159 |
|
45 |
# |
160 |
# |
46 |
# If no version was specified with any of the ver or ver+ arguments, set the |
161 |
# If no version was specified with any of the ver or ver+ arguments, allow |
47 |
# default version. |
162 |
# all versions. |
48 |
# |
163 |
# |
49 |
.if !defined(_LUA_WANTED_VERSIONS) |
164 |
.if empty(_LUA_WANTED_VERSIONS) |
50 |
_LUA_WANTED_VERSIONS= ${_LUA_DEFAULT_VERSION} |
165 |
_LUA_WANTED_VERSIONS:= ${_LUA_VALID_VERSIONS} |
51 |
.endif |
166 |
.endif |
52 |
|
167 |
|
53 |
# |
168 |
# |
54 |
# Right now we have built a list of potential versions that we may depend on. |
169 |
# By now, _LUA_WANTED_VERSIONS is the list of valid version numbers that the |
55 |
# Let's sort them and remove any duplicates. We then locate the highest one |
170 |
# caller has allowed through. We want to put the default version, if it's in |
56 |
# already installed, if any. |
171 |
# the list, first, followed by all other versions in desc order; then the |
|
|
172 |
# first element is the one we want (or the default flavor in the flavor case) |
57 |
# |
173 |
# |
58 |
.for _v in ${_LUA_WANTED_VERSIONS:O:u} |
174 |
_LUA_WANTED_VERSIONS:= \ |
59 |
_LUA_HIGHEST_VERSION:=${_v} |
175 |
${_LUA_WANTED_VERSIONS:M${_LUA_DEFAULT_VERSION}} \ |
60 |
. if exists(${LOCALBASE}/bin/lua${_v}) |
176 |
${_LUA_WANTED_VERSIONS:N${_LUA_DEFAULT_VERSION}:O:u:[-1..1]} |
61 |
_LUA_HIGHEST_INSTALLED_VERSION:= ${_v} |
177 |
|
|
|
178 |
.if ${_LUA_ARG_FLAVORS} |
179 |
. if empty(FLAVORS) |
180 |
FLAVORS= ${_LUA_WANTED_VERSIONS:S/^/lua/} |
62 |
. endif |
181 |
. endif |
63 |
.endfor |
182 |
. if empty(FLAVOR) |
|
|
183 |
FLAVOR= ${FLAVORS:[1]} |
184 |
. endif |
185 |
_LUA_WANTED_VERSION:= ${FLAVOR:S/^lua//} |
186 |
.else |
187 |
_LUA_WANTED_VERSION:= ${_LUA_WANTED_VERSIONS:[1]} |
188 |
.endif |
64 |
|
189 |
|
|
|
190 |
# If we're building Lua itself, everything should be in $PREFIX. If |
191 |
# we're building a module or app, then the stuff we're installing goes |
192 |
# in $PREFIX but references to Lua itself are in $LOCALBASE. |
65 |
# |
193 |
# |
66 |
# Depend on the default version if it fits, or the highest installed version, |
194 |
# The assumption is the LUA_MOD* directories are where we're going to |
67 |
# or the highest version. |
195 |
# install (this is common for both modules and apps), and so we also |
68 |
# |
196 |
# define LUA_REFMOD* relative to LOCALBASE for use when specifying |
69 |
.if ${_LUA_WANTED_VERSIONS:M${_LUA_DEFAULT_VERSION}} |
197 |
# dependencies and so on. |
70 |
_LUA_WANTED_VERSION:= ${_LUA_DEFAULT_VERSION} |
198 |
|
71 |
.elif defined(_LUA_HIGHEST_INSTALLED_VERSION) |
199 |
.if ${_LUA_ARG_CORE} |
72 |
_LUA_WANTED_VERSION:= ${_LUA_HIGHEST_INSTALLED_VERSION} |
200 |
LUA_BASE=${PREFIX} |
73 |
.else |
201 |
.else |
74 |
_LUA_WANTED_VERSION:= ${_LUA_HIGHEST_VERSION} |
202 |
LUA_BASE=${LOCALBASE} |
75 |
.endif |
203 |
.endif |
76 |
|
204 |
|
|
|
205 |
LUA_PREFIX=${PREFIX} |
206 |
|
77 |
# |
207 |
# |
78 |
# Exported variables |
208 |
# Exported variables |
79 |
# |
209 |
# |
80 |
LUA_VER_STR= ${_LUA_WANTED_VERSION} |
210 |
LUA_VER_STR= ${_LUA_WANTED_VERSION} |
81 |
LUA_VER= ${_LUA_WANTED_VERSION:S/5/5./} |
211 |
LUA_VER= ${_LUA_WANTED_VERSION:S/^5/5./} |
82 |
LUA_CMD= lua${_LUA_WANTED_VERSION} |
212 |
LUA_FLAVOR= ${_LUA_WANTED_VERSION:S/^/lua/} |
83 |
LUAC_CMD= luac${_LUA_WANTED_VERSION} |
213 |
|
84 |
LUA_INCDIR= ${LOCALBASE}/include/lua${_LUA_WANTED_VERSION} |
214 |
LUA_CMD= lua${LUA_VER_STR} |
85 |
LUA_MODLIBDIR= ${LOCALBASE}/lib/lua/${LUA_VER} |
215 |
LUAC_CMD= luac${LUA_VER_STR} |
86 |
LUA_MODSHAREDIR= ${LOCALBASE}/share/lua/${LUA_VER} |
|
|
87 |
LUA_LIBDIR= ${LOCALBASE}/lib |
88 |
LUA_PKGNAMEPREFIX= lua${LUA_VER_STR}- |
216 |
LUA_PKGNAMEPREFIX= lua${LUA_VER_STR}- |
89 |
|
217 |
|
90 |
PLIST_SUB+= LUA_MODLIBDIR=${LUA_MODLIBDIR:S,^${LOCALBASE}/,,} \ |
218 |
LUA_LIBDIR= ${LUA_BASE}/lib |
91 |
LUA_MODSHAREDIR=${LUA_MODSHAREDIR:S,^${LOCALBASE}/,,} \ |
219 |
LUA_INCDIR= ${LUA_BASE}/include/lua${LUA_VER_STR} |
|
|
220 |
|
221 |
LUA_MODLIBDIR= ${LUA_PREFIX}/lib/lua/${LUA_VER} |
222 |
LUA_MODSHAREDIR= ${LUA_PREFIX}/share/lua/${LUA_VER} |
223 |
LUA_MODDOCSDIR= ${LUA_PREFIX}/share/doc/lua${LUA_VER_STR} |
224 |
LUA_MODEXAMPLESDIR= ${LUA_PREFIX}/share/examples/lua${LUA_VER_STR} |
225 |
|
226 |
LUA_REFMODLIBDIR= ${LUA_BASE}/lib/lua/${LUA_VER} |
227 |
LUA_REFMODSHAREDIR= ${LUA_BASE}/share/lua/${LUA_VER} |
228 |
|
229 |
PLIST_SUB+= LUA_MODLIBDIR=${LUA_MODLIBDIR:S,^${LUA_PREFIX}/,,} \ |
230 |
LUA_MODSHAREDIR=${LUA_MODSHAREDIR:S,^${LUA_PREFIX}/,,} \ |
231 |
LUA_MODDOCSDIR=${LUA_MODDOCSDIR:S,^${LUA_PREFIX}/,,} \ |
232 |
LUA_INCDIR=${LUA_INCDIR:S,^${LUA_BASE}/,,} \ |
233 |
LUA_LIBDIR=${LUA_LIBDIR:S,^${LUA_BASE}/,,} \ |
92 |
LUA_VER=${LUA_VER} \ |
234 |
LUA_VER=${LUA_VER} \ |
93 |
LUA_INCDIR=${LUA_INCDIR:S,^${LOCALBASE}/,,} \ |
|
|
94 |
LUA_LIBDIR=${LUA_LIBDIR:S,^${LOCALBASE}/,,} \ |
95 |
LUA_VER_STR=${LUA_VER_STR} |
235 |
LUA_VER_STR=${LUA_VER_STR} |
96 |
MAKE_ENV+= LUA_MODLIBDIR=${LUA_MODLIBDIR} \ |
236 |
MAKE_ENV+= LUA_MODLIBDIR=${LUA_MODLIBDIR} \ |
97 |
LUA_MODSHAREDIR=${LUA_MODSHAREDIR} \ |
237 |
LUA_MODSHAREDIR=${LUA_MODSHAREDIR} \ |
98 |
LUA_VER=${LUA_VER} \ |
238 |
LUA_MODDOCSDIR=${LUA_MODDOCSDIR} \ |
99 |
LUA_INCDIR=${LUA_INCDIR} \ |
239 |
LUA_INCDIR=${LUA_INCDIR} \ |
100 |
LUA_LIBDIR=${LUA_LIBDIR} |
240 |
LUA_LIBDIR=${LUA_LIBDIR} \ |
|
|
241 |
LUA_VER=${LUA_VER} \ |
242 |
LUA_VER_STR=${LUA_VER_STR} |
243 |
|
244 |
# if building a module or Lua itself, or if the port defined LUA_DOCSUBDIR, |
245 |
# then define LUA_DOCSDIR and LUA_EXAMPLESDIR too |
246 |
.if ${_LUA_ARG_CORE} || ${_LUA_ARG_MODULE} |
247 |
LUA_DOCSUBDIR?=${PORTNAME} |
248 |
.endif |
249 |
.if !empty(LUA_DOCSUBDIR) |
250 |
LUA_DOCSDIR= ${LUA_MODDOCSDIR}/${LUA_DOCSUBDIR} |
251 |
LUA_EXAMPLESDIR=${LUA_MODEXAMPLESDIR}/${LUA_DOCSUBDIR} |
252 |
PLIST_SUB+= LUA_DOCSDIR=${LUA_DOCSDIR:S,^${LUA_PREFIX}/,,} |
253 |
PLIST_SUB+= LUA_EXAMPLESDIR=${LUA_EXAMPLESDIR:S,^${LUA_PREFIX}/,,} |
254 |
MAKE_ENV+= LUA_DOCSDIR=${LUA_DOCSDIR} |
255 |
MAKE_ENV+= LUA_EXAMPLESDIR=${LUA_EXAMPLESDIR} |
256 |
.endif |
101 |
|
257 |
|
102 |
.if ${lua_ARGS:Mbuild} |
258 |
.if empty(_LUA_ARG_ENV) |
|
|
259 |
. if ${lua_ARGS:Mbuild} |
103 |
BUILD_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} |
260 |
BUILD_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} |
104 |
.elif ${lua_ARGS:Mrun} |
261 |
. endif |
|
|
262 |
. if ${lua_ARGS:Mrun} |
105 |
RUN_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} |
263 |
RUN_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} |
106 |
.else |
264 |
. endif |
|
|
265 |
. if !${lua_ARGS:Mbuild} && !${lua_ARGS:Mrun} |
107 |
LIB_DEPENDS+= liblua-${LUA_VER}.so:lang/lua${LUA_VER_STR} |
266 |
LIB_DEPENDS+= liblua-${LUA_VER}.so:lang/lua${LUA_VER_STR} |
|
|
267 |
. endif |
108 |
.endif |
268 |
.endif |
109 |
|
269 |
|
110 |
.endif |
270 |
.endif |