Added
Link Here
|
1 |
#-*- mode: makefile; tab-width: 4; -*- |
2 |
# ex:ts=4 |
3 |
# |
4 |
# $FreeBSD$ |
5 |
# |
6 |
# bsd.lua.mk - Support for Lua based ports. |
7 |
# |
8 |
# Created by: Alejandro Pulver <alepulver@FreeBSD.org> |
9 |
# |
10 |
# Please view me with 4 column tabs! |
11 |
# |
12 |
# The following variables can be defined in a port that uses the Lua library, |
13 |
# tolua, Ruby bindings or related components like .lua modules (with run |
14 |
# and/or build dependencies). It can be used after and/or before |
15 |
# bsd.port.pre.mk, but Ruby components will only work if Ruby variables (e.g. |
16 |
# USE_RUBY) are defined before it (this is a bsd.ruby.mk limitation), at least |
17 |
# it is manually included. |
18 |
# USE_LUA - Set to the list of Lua versions that can be used by the |
19 |
# port. The syntax allows the following elements: |
20 |
# - Single version (e.g. "4.0"). |
21 |
# - Range of versions (e.g. "5.0-5.1"). Must be ascending. |
22 |
# - Partial range: single version and upper (e.g. "5.0+"). |
23 |
# - Partial range: single version and lower (e.g. "5.1-"). |
24 |
# Multiple elements can be specified separated by spaces. |
25 |
# USE_LUA_NOT - Set to the list of Lua versions that can't be used by the |
26 |
# port. In other words, it removes some versions from USE_LUA. |
27 |
# If the latter is not defined, it will have the value of all |
28 |
# the possible versions. The syntax is like USE_LUA. |
29 |
# LUA_COMPS - Set to the list of Lua components the port uses. Several |
30 |
# components can be specified separated by spaces. By default |
31 |
# it will have the value of "lua". Suffixes in the form ":xxx" |
32 |
# may be added to the components to determine the dependency |
33 |
# type. |
34 |
# The available components are: |
35 |
# lua - The Lua library. |
36 |
# tolua - The tolua library (vers 4.0-5.0). |
37 |
# ruby - The Ruby bindings for Lua (vers 4.0-5.0). |
38 |
# app, compat51, dfui, filename, gettext, posix, pty and |
39 |
# socket - Modules for Lua 5.0. |
40 |
# The available dependency types are: |
41 |
# build - Requires component for building. |
42 |
# lib - Requires component for building and running. |
43 |
# run - Requires component for running. |
44 |
# If no suffix is present then "lib" will be used for "lua" |
45 |
# 4.0-5.0 and "ruby", "build" for lua 5.1 and "tolua" (they |
46 |
# are static), all others default to "run". |
47 |
# LUA_PREMK - Define to determine version and define variables after |
48 |
# <bsd.port.pre.mk> (in case the port needs to manually run |
49 |
# the Lua program or the like). |
50 |
# WANT_LUA - Set to "yes" or a valid single version (no ranges, etc). |
51 |
# In both cases it will detect the installed Lua components |
52 |
# and add them to the variable HAVE_LUA. If a version is |
53 |
# selected, HAVE_LUA will contain a list of components in the |
54 |
# other case it will contain a list of "component-version" |
55 |
# pairs (e.g. lua-4.0, tolua-5.1, etc). |
56 |
# It has to be used before bsd.port.pre.mk. |
57 |
# WANT_LUA_VER - Set to the prefered Lua version for the port. It must be |
58 |
# present in USE_LUA or missing in USE_LUA_NOT. This is |
59 |
# overriden by the user variable WITH_LUA_VER if set. It can |
60 |
# contain multiple versions in order of preference (last ones |
61 |
# are tried first). |
62 |
# |
63 |
# The following variables are intended for the user and can be defined in |
64 |
# make.conf. |
65 |
# WITH_LUA_VER - Define to the list of prefered versions in reverse order. |
66 |
# |
67 |
# The following variables are defined by this file, to be read from the port. |
68 |
# HAVE_LUA - The list of Lua components installed, if WANT_LUA was |
69 |
# defined. The components will have version suffix if it was |
70 |
# set to "yes". |
71 |
# LUA_VER - The Lua version that is going to be used (e.g. "5.1"). |
72 |
# LUA_VER_SH - The Lua shared library major version (e.g. "1"). |
73 |
# LUA_VER_STR - The Lua version without the dots (e.g. "51"). |
74 |
# LUA_PREFIX - The prefix where Lua (and components) is installed. |
75 |
# LUA_SUBDIR - The directory under bin/share/lib where Lua is installed. |
76 |
# LUA_INCDIR - The directory where Lua and tolua header files are installed. |
77 |
# LUA_LIBDIR - The directory where Lua and tolua libraries are installed. |
78 |
# LUA_MODLIBDIR - The directory where Lua modules (.lua) are installed. |
79 |
# LUA_MODSHAREDIR - The directory where Lua module libraries (.so) are |
80 |
# installed. |
81 |
# LUA_PKGNAMEPREFIX - The package name prefix used by Lua modules. |
82 |
# |
83 |
# Examples: |
84 |
# - A port that needs Lua 4.0 and tolua (also 4.0) libraries (lua for building |
85 |
# and running and tolua for building). |
86 |
# USE_LUA= 4.0 |
87 |
# LUA_COMPS= lua tolua |
88 |
# - A port that needs Ruby bindings for Lua 5.0 for building and running. |
89 |
# USE_LUA= 5.0 |
90 |
# LUA_COMPS= ruby |
91 |
# - A port that needs tolua 5.0 or 5.1 for building. |
92 |
# USE_LUA= 5.0 5.1 |
93 |
# LUA_COMPS= tolua |
94 |
# - A port that needs Lua version 5.0 or higher for building and running. |
95 |
# USE_LUA= 5.0+ |
96 |
# - A port that needs Lua of any version other than 5.1 for building and |
97 |
# running. |
98 |
# USE_LUA_NOT=5.1 |
99 |
# |
100 |
|
101 |
LUA_Include_MAINTAINER= alepulver@FreeBSD.org |
102 |
|
103 |
# |
104 |
# Global definitions. |
105 |
# |
106 |
|
107 |
.if !defined(_LUA_Definitions_Done) |
108 |
_LUA_Definitions_Done= yes |
109 |
|
110 |
# Common variables: |
111 |
# _LUA_COMPS_ALL - List of valid components. |
112 |
# _LUA_DEP_TYPES_ALL - List of valid dependency types. |
113 |
# _LUA_VERS_ALL - List of available Lua versions. |
114 |
# _LUA_VERS_LISTS= - Reverse lists preference order. |
115 |
# _LUA_PLIST_ALL - List of variables to be added to PLIST_SUB. |
116 |
# _LUA_PLIST_DIR_ALL - List of path variables (relative to ${LUA_PREFIX}) |
117 |
# to be added to PLIST_SUB. |
118 |
# |
119 |
|
120 |
_LUA_COMPS_ALL= lua tolua ruby \ |
121 |
app compat51 dfui filename gettext posix pty socket |
122 |
_LUA_DEP_TYPES_ALL= build lib run |
123 |
_LUA_VERS_ALL= 4.0 5.0 5.1 |
124 |
_LUA_PLIST_ALL= LUA_VER LUA_VER_SH LUA_VER_STR LUA_PREFIX LUA_SUBDIR |
125 |
_LUA_PLIST_DIR_ALL= LUA_BINDIR LUA_INCDIR LUA_LIBDIR \ |
126 |
LUA_MODLIBDIR LUA_MODSHAREDIR |
127 |
_LUA_VERS_LISTS= WANT_LUA_VER WITH_LUA_VER |
128 |
|
129 |
# |
130 |
# Variables used to determine what is needed. |
131 |
# _LUA_PORT_comp_ver - Port directory. |
132 |
# _LUA_LIB_comp_ver - Name of the shared library (optional). |
133 |
# _LUA_SHVER_comp_ver - Shared library version (optional). |
134 |
# _LUA_FILE_comp_ver - File installed by that component. |
135 |
# _LUA_DEPTYPE_comp_ver - Default dependency type. |
136 |
# |
137 |
|
138 |
_LUA_PORT_lua_4.0= lang/lua4 |
139 |
_LUA_DEPTYPE_lua_4.0= lib |
140 |
_LUA_PORT_tolua_4.0= lang/tolua4 |
141 |
_LUA_PORT_ruby_4.0= lang/ruby-lua4 |
142 |
|
143 |
_LUA_PORT_lua_5.0= lang/lua50 |
144 |
_LUA_DEPTYPE_lua_5.0= lib |
145 |
_LUA_PORT_tolua_5.0= lang/tolua |
146 |
_LUA_PORT_ruby_5.0= lang/ruby-lua |
147 |
|
148 |
_LUA_PORT_app_5.0= devel/lua50-app |
149 |
_LUA_PORT_compat51_5.0= devel/lua50-compat51 |
150 |
_LUA_FILE_compat51_5.0= ${LUA_MODSHAREDIR}/compat-5.1.lua |
151 |
_LUA_PORT_dfui_5.0= devel/lua50-dfui |
152 |
_LUA_PORT_filename_5.0= devel/lua50-filename |
153 |
_LUA_PORT_gettext_5.0= devel/lua50-gettext |
154 |
_LUA_PORT_posix_5.0= devel/lua50-posix |
155 |
_LUA_PORT_pty_5.0= devel/lua50-pty |
156 |
_LUA_PORT_socket_5.0= net/luasocket |
157 |
|
158 |
_LUA_PORT_lua_5.1= lang/lua |
159 |
_LUA_DEPTYPE_lua_5.1= build |
160 |
|
161 |
.for comp in ${_LUA_COMPS_ALL} |
162 |
_LUA_COMP= ${comp} |
163 |
. for ver in ${_LUA_VERS_ALL} |
164 |
. if ${_LUA_COMP} == "lua" |
165 |
_LUA_LIB_${comp}_${ver}= lua-${LUA_VER}.${LUA_VER_SH} |
166 |
_LUA_SHVER_${comp}_${ver}= ${LUA_VER_SH} |
167 |
_LUA_FILE_${comp}_${ver}= ${LUA_LIBDIR}/liblua.a |
168 |
. elif ${_LUA_COMP} == "tolua" |
169 |
_LUA_FILE_${comp}_${ver}= ${LUA_LIBDIR}/libtolua.a |
170 |
_LUA_DEPTYPE_${comp}_${ver}=build |
171 |
. elif ${_LUA_COMP} == "ruby" |
172 |
_LUA_FILE_${comp}_${ver}= ${RUBY_SITEARCHLIBDIR}/lua-${LUA_VER}.so |
173 |
_LUA_DEPTYPE_${comp}_${ver}=lib |
174 |
. else |
175 |
. if !defined(_LUA_FILE_${comp}_${ver}) |
176 |
_LUA_FILE_${comp}_${ver}= ${LUA_MODSHAREDIR}/${comp}.lua |
177 |
. endif |
178 |
_LUA_DEPTYPE_${comp}_${ver}=run |
179 |
. endif |
180 |
. endfor |
181 |
.endfor |
182 |
|
183 |
.endif |
184 |
|
185 |
# |
186 |
# Check for present components. |
187 |
# |
188 |
|
189 |
.if defined(WANT_LUA) && !defined(AFTERPORTMK) |
190 |
. for __WANT_LUA in ${WANT_LUA} |
191 |
# Check if WANT_LUA contains more than one word. |
192 |
. if defined(HAVE_LUA) |
193 |
IGNORE?= selected multiple values for WANT_LUA: ${WANT_LUA} |
194 |
. endif |
195 |
HAVE_LUA= # |
196 |
# Check for all versions. |
197 |
. if ${WANT_LUA:L} == "yes" |
198 |
. for comp in ${_LUA_COMPS_ALL} |
199 |
. for ver in ${_LUA_VERS_ALL} |
200 |
_LUA_COMP= _LUA_FILE_${comp}_${ver} |
201 |
. if defined(${_LUA_COMP}) && exists(${${_LUA_COMP}}) |
202 |
HAVE_LUA+= ${comp}-${ver} |
203 |
. endif |
204 |
. endfor |
205 |
. endfor |
206 |
# Check for a specific version. |
207 |
. elif ${_LUA_VERS_ALL:M${__WANT_LUA}} != "" |
208 |
. for comp in ${_LUA_COMPS_ALL} |
209 |
. if exists(${_LUA_FILE_${comp}_${__WANT_LUA}}) |
210 |
HAVE_LUA+= ${comp} |
211 |
. endif |
212 |
. endfor |
213 |
. else |
214 |
IGNORE?= selected an invalid value for WANT_LUA: ${__WANT_LUA} |
215 |
. endif |
216 |
. endfor |
217 |
.endif # WANT_LUA && !AFTERPORTMK |
218 |
|
219 |
# |
220 |
# Select Lua version. |
221 |
# |
222 |
|
223 |
.if !defined(_LUA_Version_Done) && (!defined(BEFOREPORTMK) || \ |
224 |
(defined(LUA_PREMK) && !defined(AFTERPORTMK) && \ |
225 |
(defined(USE_LUA) || defined(USE_LUA_NOT)))) |
226 |
_LUA_Version_Done= yes |
227 |
|
228 |
# Set defaults (if one isn't present). |
229 |
|
230 |
USE_LUA?= ${_LUA_VERS_ALL} |
231 |
USE_LUA_NOT?= # |
232 |
|
233 |
# |
234 |
# Make lists of valid and invalid versions. |
235 |
# |
236 |
# The following variables are used: |
237 |
# _LUA_VER_CHECK - If the version is a single one, express in a range. |
238 |
# _LUA_VER_MIN - Lower version of the range. |
239 |
# _LUA_VER_MAX - Higher version of the range. |
240 |
# _LUA_VER_LIST - List of requested versions. |
241 |
# _LUA_VER_NOT_LIST - List of disallowed versions. |
242 |
# _LUA_VER_FINAL - List of requested version without disallowed ones. |
243 |
# |
244 |
|
245 |
.for list in VER VER_NOT |
246 |
_LUA_${list}_LIST= # |
247 |
. for ver in ${USE_LUA${list:C/VER//}} |
248 |
_LUA_VER_CHECK:= ${ver:C/^([[:digit:]]+(\.[[:digit:]]+)*)$/\1-\1/} |
249 |
_LUA_VER_MIN:= ${_LUA_VER_CHECK:C/([[:digit:]]+(\.[[:digit:]]+)*)[-+].*/\1/} |
250 |
_LUA_VER_MAX:= ${_LUA_VER_CHECK:C/.*-([[:digit:]]+(\.[[:digit:]]+)*)/\1/} |
251 |
# Minimum version not specified. |
252 |
. if ${_LUA_VER_MIN} == ${_LUA_VER_CHECK} |
253 |
. undef _LUA_VER_MIN |
254 |
. for v in ${_LUA_VERS_ALL} |
255 |
_LUA_VER_MIN?= ${v} |
256 |
. endfor |
257 |
. endif |
258 |
# Maximum version not specified. |
259 |
. if ${_LUA_VER_MAX} == ${_LUA_VER_CHECK} |
260 |
. for v in ${_LUA_VERS_ALL} |
261 |
_LUA_VER_MAX= ${v} |
262 |
. endfor |
263 |
. endif |
264 |
# Expand versions and add valid ones to each list. |
265 |
. for v in ${_LUA_VERS_ALL} |
266 |
. if ${_LUA_VER_MIN} <= ${v} && ${_LUA_VER_MAX} >= ${v} && \ |
267 |
${_LUA_${list}_LIST:M${v}} == "" |
268 |
_LUA_${list}_LIST+= ${v} |
269 |
. endif |
270 |
. endfor |
271 |
. endfor |
272 |
.endfor |
273 |
|
274 |
# Merge the lists into a single list of valid versions. |
275 |
|
276 |
_LUA_VER_FINAL= # |
277 |
.for ver in ${_LUA_VER_LIST} |
278 |
. if ${_LUA_VER_NOT_LIST:M${ver}} == "" |
279 |
_LUA_VER_FINAL+= ${ver} |
280 |
. endif |
281 |
.endfor |
282 |
|
283 |
# Check for a null version. |
284 |
|
285 |
.if empty(_LUA_VER_FINAL) |
286 |
IGNORE?= selected a null or invalid Lua version |
287 |
.endif |
288 |
|
289 |
# |
290 |
# Choose final version. |
291 |
# |
292 |
|
293 |
# |
294 |
# Check for the following (in order): |
295 |
# 1) WITH_LUA_VER - User preference. |
296 |
# 2) WANT_LUA_VER - Port preference. |
297 |
# 3) _LUA_VER_FINAL - Available versions. |
298 |
# |
299 |
|
300 |
.for list in _LUA_VER_FINAL ${_LUA_LISTS_ORDER} |
301 |
. if defined(${list}) |
302 |
. for ver in ${${list}} |
303 |
. if ${_LUA_VER_FINAL:M${ver}} != "" |
304 |
_LUA_VER= ${ver} |
305 |
. endif |
306 |
. endfor |
307 |
. endif |
308 |
.endfor |
309 |
|
310 |
# |
311 |
# Set variables. |
312 |
# |
313 |
|
314 |
# Version. |
315 |
LUA_VER= ${_LUA_VER} |
316 |
LUA_VER_SH?= ${LUA_VER:C/[[:digit:]]\.([[:digit:]])/\1/} |
317 |
LUA_VER_STR?= ${LUA_VER:S/.//g} |
318 |
|
319 |
# Paths. |
320 |
LUA_PREFIX?= ${LOCALBASE} |
321 |
LUA_SUBDIR?= lua${LUA_VER_STR} |
322 |
LUA_BINDIR?= ${LUA_PREFIX}/bin/${LUA_SUBDIR} |
323 |
LUA_INCDIR?= ${LUA_PREFIX}/include/${LUA_SUBDIR} |
324 |
LUA_LIBDIR?= ${LUA_PREFIX}/lib/${LUA_SUBDIR} |
325 |
LUA_MODLIBDIR?= ${LUA_PREFIX}/lib/lua/${LUA_VER} |
326 |
LUA_MODSHAREDIR?= ${LUA_PREFIX}/share/lua/${LUA_VER} |
327 |
|
328 |
# Package name. |
329 |
LUA_PKGNAMEPREFIX?= lua${LUA_VER_STR}- |
330 |
|
331 |
.endif # !_LUA_Version_Done && (!BEFOREPORTMK || \ |
332 |
# (LUA_PREMK && !AFTERPORTMK && (USE_LUA || USE_LUA_NOT))) |
333 |
|
334 |
# |
335 |
# Process components list and add dependencies, variables, etc. |
336 |
# |
337 |
|
338 |
.if !defined(BEFOREPORTMK) |
339 |
|
340 |
# |
341 |
# Component parsing. |
342 |
# |
343 |
# The variables used are: |
344 |
# _LUA_COMP - Component part. |
345 |
# _LUA_DEP_TYPE - Dependency type part. |
346 |
# _LUA_COMP_NEW - Component + dependency type. |
347 |
# _LUA_COMPS_FINAL - Final list of components with dependency types. |
348 |
# |
349 |
|
350 |
# Default components. |
351 |
|
352 |
LUA_COMPS?= lua |
353 |
|
354 |
# Detect invalid and duplicated components. |
355 |
|
356 |
_LUA_COMPS_FINAL= # |
357 |
.for comp in ${LUA_COMPS} |
358 |
_LUA_COMP= ${comp:C/:([[:alpha:]]+)$//} |
359 |
. if ${_LUA_COMP} == ${comp} |
360 |
_LUA_DEP_TYPE= ${_LUA_DEPTYPE_${comp}_${_LUA_VER}} |
361 |
. else |
362 |
_LUA_DEP_TYPE= ${comp:C/.+:([[:alpha:]]+)$/\1/} |
363 |
. endif |
364 |
_LUA_COMP_NEW= ${_LUA_COMP}_${_LUA_DEP_TYPE} |
365 |
. for __LUA_COMP in ${_LUA_COMP} |
366 |
. if ${_LUA_COMPS_ALL:M${__LUA_COMP}} == "" |
367 |
IGNORE?= selected an invalid Lua component: ${__LUA_COMP} |
368 |
. endif |
369 |
. endfor |
370 |
. for __LUA_DEP_TYPE in ${_LUA_DEP_TYPE} |
371 |
. if ${_LUA_DEP_TYPES_ALL:M${__LUA_DEP_TYPE}} == "" |
372 |
IGNORE?= selected an invalid Lua dependency type: ${__LUA_DEP_TYPE} |
373 |
. endif |
374 |
. endfor |
375 |
. if !defined(_LUA_PORT_${_LUA_COMP}_${_LUA_VER}) |
376 |
IGNORE?= selected a Lua component (${_LUA_COMP}) which is not available for the selected version (${_LUA_VER}) |
377 |
. endif |
378 |
. for newcomp in ${_LUA_COMP_NEW} |
379 |
. if ${_LUA_COMPS_FINAL:M${newcomp}} == "" |
380 |
_LUA_COMPS_FINAL+= ${newcomp} |
381 |
. endif |
382 |
. endfor |
383 |
.endfor |
384 |
|
385 |
# Add dependencies. |
386 |
# |
387 |
# The variable used are: |
388 |
# _LUA_COMP - - Component part. |
389 |
# _LUA_DEP_TYPE - Dependency type part. |
390 |
|
391 |
.for comp in ${_LUA_COMPS_FINAL} |
392 |
_LUA_DEP_TYPE= ${comp:C/.+_([[:alpha:]]+)$/\1/} |
393 |
_LUA_COMP= ${comp:C/_([[:alpha:]]+)$//} |
394 |
# XXX Need a .for loop here so the variable is expanded before the assignment. |
395 |
. for comp_part in ${_LUA_COMP} |
396 |
. if ${_LUA_DEP_TYPE} == "lib" |
397 |
. if defined(_LUA_LIB_${comp_part}_${_LUA_VER}) |
398 |
LIB_DEPENDS+= ${_LUA_LIB_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}} |
399 |
. else |
400 |
BUILD_DEPENDS+= ${_LUA_FILE_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}} |
401 |
RUN_DEPENDS+= ${_LUA_FILE_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}} |
402 |
. endif |
403 |
. else |
404 |
${_LUA_DEP_TYPE:U}_DEPENDS+= ${_LUA_FILE_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}} |
405 |
. endif |
406 |
. endfor |
407 |
.endfor |
408 |
|
409 |
# Packaging list variables. |
410 |
.for var in ${_LUA_PLIST_ALL} |
411 |
PLIST_SUB+= ${var}="${${var}}" |
412 |
.endfor |
413 |
.for var in ${_LUA_PLIST_DIR_ALL} |
414 |
PLIST_SUB+= ${var}="${${var}:S/${LUA_PREFIX}\///}" |
415 |
.endfor |
416 |
.for var in ${_LUA_PLIST_ALL} ${_LUA_PLIST_DIR_ALL} |
417 |
MAKE_ENV+= ${var}="${${var}}" |
418 |
.endfor |
419 |
|
420 |
.endif # ! BEFOREPORTMK |