Sync Mk with ports
[dports.git] / Mk / bsd.lua.mk
1 #-*- tab-width: 4; -*-
2 # ex:ts=4
3 #
4 # $FreeBSD: Mk/bsd.lua.mk 334220 2013-11-18 16:15:51Z bapt $
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 (for 4.0-5.1).
37 #                                 toluaxx               - The tolua++ library (for 5.0-5.1).
38 #                                 ruby                  - The Ruby bindings for Lua (for 4.0-5.0).
39 #                                 Other components (modules):
40 #                                 5.0                   - app, compat51, dfui, filename, gettext,
41 #                                                                 posix, pty, socket.
42 #                                 5.1                   - alien, filename, gettext, posix, pty, socket.
43 #                                 The available dependency types are:
44 #                                 build                 - Requires component for building.
45 #                                 lib                   - Requires component for building and running.
46 #                                 run                   - Requires component for running.
47 #                                 If no suffix is present then "lib" will be used for "lua"
48 #                                 4.0-5.0 and "ruby", "build" for lua 5.1 and "tolua" (they
49 #                                 are static), all others default to "run".
50 # LUA_PREMK             - Define to determine version and define variables after
51 #                                 <bsd.port.pre.mk> (in case the port needs to manually run
52 #                                 the Lua program or the like).
53 # WANT_LUA              - Set to "yes" or a valid single version (no ranges, etc).
54 #                                 In both cases it will detect the installed Lua components
55 #                                 and add them to the variable HAVE_LUA. If a version is
56 #                                 selected, HAVE_LUA will contain a list of components in the
57 #                                 other case it will contain a list of "component-version"
58 #                                 pairs (e.g. lua-4.0, tolua-5.1, etc).
59 #                                 It has to be used before bsd.port.pre.mk.
60 # WANT_LUA_VER  - Set to the prefered Lua version for the port. It must be
61 #                                 present in USE_LUA or missing in USE_LUA_NOT. This is
62 #                                 overriden by the user variable WITH_LUA_VER if set. It can
63 #                                 contain multiple versions in order of preference (last ones
64 #                                 are tried first).
65 #
66 # The following variables are intended for the user and can be defined in
67 # make.conf.
68 # WITH_LUA_VER  - Define to the list of prefered versions in reverse order.
69 #
70 # The following variables are defined by this file, to be read from the port.
71 # HAVE_LUA              - The list of Lua components installed, if WANT_LUA was
72 #                                 defined. The components will have version suffix if it was
73 #                                 set to "yes".
74 # LUA_VER               - The Lua version that is going to be used (e.g. "5.1").
75 # LUA_VER_SH    - The Lua shared library major version (e.g. "1").
76 # LUA_VER_STR   - The Lua version without the dots (e.g. "51").
77 # LUA_PREFIX    - The prefix where Lua (and components) is installed.
78 #                                 NOTE: please see comments below about its double function.
79 # LUA_SUBDIR    - The directory under bin/share/lib where Lua is installed.
80 #                                 Also used by Lua ports (lang/lua*) to set LATEST_LINK.
81 # LUA_INCDIR    - The directory where Lua, tolua and tolua++ header files are
82 #                                 installed.
83 # LUA_LIBDIR    - The directory where Lua, tolua and tolua++ libraries are
84 #                                 installed.
85 # LUA_MODLIBDIR - The directory where Lua module libraries (.so) are installed.
86 # LUA_MODSHAREDIR
87 #                               - The directory where Lua modules (.lua) are installed.
88 # LUA_PKGNAMEPREFIX
89 #                               - The package name prefix used by Lua modules.
90 # LUA_CMD               - The path to the Lua interpreter.
91 # LUAC_CMD              - The path to the Lua compiler.
92 # TOLUA_CMD             - The path to the tolua program.
93 # TOLUAXX_CMD   - The path to the tolua++ program.
94 #
95 # Examples:
96 # - A port that needs Lua 4.0 and tolua (also 4.0) libraries (lua for building
97 #       and running and tolua for building).
98 #       USE_LUA=        4.0
99 #       LUA_COMPS=      lua tolua
100 # - A port that needs Ruby bindings for Lua 5.0 for building and running.
101 #       USE_LUA=        5.0
102 #       LUA_COMPS=      ruby
103 # - A port that needs tolua 5.0 or 5.1 for building.
104 #       USE_LUA=        5.0 5.1
105 #       LUA_COMPS=      tolua
106 # - A port that needs Lua version 5.0 or higher for building and running.
107 #       USE_LUA=        5.0+
108 # - A port that needs Lua of any version other than 5.1 for building and
109 #       running.
110 #       USE_LUA_NOT=5.1
111 #
112 # Notes about the integration of lua related ports with bsd.lua.mk:
113 # (please read when updating ports referred here, see lang/lua[0-9]*)
114 #
115 # The lua/tolua ports have to be patched so they can coexist, as the internal
116 # application build infrastructure does not handle it automatically. Currently
117 # the framework provides variables to the lua ports themselves, so changing
118 # some things here won't require changes in lang/{lua,tolua}*.
119 #
120 # For lua ports: if they install a static library, use the same method for
121 # tolua ports, otherwise in addition the libraries have to be symlinked to the
122 # common library directory with a versioned name, and linked with the -soname
123 # parameter (so when a port links with -L/usr/local/lib/lua51 -llua, it stores
124 # the dynamic dependency as the name which figures under /usr/local/lib).
125 #
126 # For tolua ports: as it is a static library (.a), installing binaries,
127 # headers and libraries under a versioned directory is fine (binary has also a
128 # symlink).
129 #
130 # The lua modules install in a separate directory, so there is no problem.
131 #
132
133 LUA_Include_MAINTAINER= lua@FreeBSD.org
134
135 #
136 # Global definitions.
137 #
138
139 .if !defined(_LUA_Definitions_Done)
140 _LUA_Definitions_Done=  yes
141
142 # Common variables:
143 # _LUA_COMPS_ALL                - List of valid components.
144 # _LUA_DEP_TYPES_ALL    - List of valid dependency types.
145 # _LUA_VERS_ALL                 - List of available Lua versions.
146 # _LUA_VERS_LISTS=              - Reverse lists preference order.
147 # _LUA_PLIST_ALL                - List of variables to be added to PLIST_SUB.
148 # _LUA_PLIST_DIR_ALL    - List of path variables (relative to ${LUA_PREFIX})
149 #                                                 to be added to PLIST_SUB.
150 #
151
152 _LUA_COMPS_ALL=                 lua tolua toluaxx ruby \
153                                                 alien app compat51 dfui filename gettext posix \
154                                                 pty socket
155 _LUA_DEP_TYPES_ALL=             build lib run
156 _LUA_VERS_ALL=                  5.1
157 _LUA_PLIST_ALL=                 LUA_VER LUA_VER_SH LUA_VER_STR LUA_PREFIX LUA_SUBDIR
158 _LUA_PLIST_DIR_ALL=             LUA_BINDIR LUA_INCDIR LUA_LIBDIR \
159                                                 LUA_MODLIBDIR LUA_MODSHAREDIR
160 _LUA_VERS_LISTS=                _LUA_VER_INSTALLED WANT_LUA_VER WITH_LUA_VER
161
162 #
163 # Variables used to determine what is needed.
164 # _LUA_PORT_comp_ver    - Port directory.
165 # _LUA_LIB_comp_ver             - Name of the shared library (optional).
166 # _LUA_SHVER_comp_ver   - Shared library version (optional).
167 # _LUA_FILE_comp_ver    - File installed by that component.
168 # _LUA_DEPTYPE_comp_ver - Default dependency type.
169 #
170
171 _LUA_PORT_lua_5.1=              lang/lua
172 _LUA_DEPTYPE_lua_5.1=   lib
173
174 _LUA_PORT_alien_5.1=    devel/lua-alien
175 _LUA_PORT_filename_5.1= devel/lua-filename
176 _LUA_PORT_gettext_5.1=  devel/lua-gettext
177 _LUA_PORT_posix_5.1=    devel/lua-posix
178 _LUA_PORT_pty_5.1=              devel/lua-pty
179 _LUA_PORT_socket_5.1=   net/luasocket
180 _LUA_PORT_tolua_5.1=    lang/tolua
181 _LUA_PORT_toluaxx_5.1=  lang/tolua++
182
183 .       for comp in ${_LUA_COMPS_ALL}
184 _LUA_COMP=                              ${comp}
185 .               for ver in ${_LUA_VERS_ALL}
186 # XXX The hardcoded values here have to match LUA_* variables (later), and
187 # are here only to allow autodetection of installed versions.
188 .                       if ${_LUA_COMP} == "lua"
189 _LUA_LIB_${comp}_${ver}=        lua-${ver}.${_LUA_SHVER_${comp}_${ver}}
190 _LUA_SHVER_${comp}_${ver}=      ${ver:C/[[:digit:]]\.([[:digit:]])/\1/}
191 _LUA_FILE_${comp}_${ver}=       ${LOCALBASE}/lib/lua${ver:S/.//g}/liblua.a
192 .                       elif ${_LUA_COMP} == "tolua"
193 _LUA_FILE_${comp}_${ver}=       ${LOCALBASE}/lib/lua${ver:S/.//g}/libtolua.a
194 _LUA_DEPTYPE_${comp}_${ver}=build
195 .                       elif ${_LUA_COMP} == "toluaxx"
196 _LUA_FILE_${comp}_${ver}=       ${LOCALBASE}/lib/lua${ver:S/.//g}/libtolua++.so
197 _LUA_DEPTYPE_${comp}_${ver}=lib
198 .                       elif ${_LUA_COMP} == "ruby"
199 _LUA_FILE_${comp}_${ver}=       ${RUBY_SITEARCHLIBDIR}/lua-${ver}.so
200 _LUA_DEPTYPE_${comp}_${ver}=lib
201 .                       elif !defined(_LUA_FILE_${comp}_${ver})
202 _LUA_FILE_${comp}_${ver}=       ${LOCALBASE}/share/lua/${ver}/${comp}.lua
203 .                       endif
204 .                       if !defined(_LUA_DEPTYPE_${comp}_${ver})
205 _LUA_DEPTYPE_${comp}_${ver}=run
206 .                       endif
207 .               endfor
208 .       endfor
209 .endif
210
211 #
212 # Check if we are going to determine the version.
213 #
214
215 .if !defined(_LUA_Version_Done) && (defined(_POSTMKINCLUDED) || \
216     (defined(LUA_PREMK) && defined(BEFOREPORTMK) && \
217     (defined(USE_LUA) || defined(USE_LUA_NOT))))
218 _LUA_Need_Version=                      yes
219 .endif
220
221 #
222 # Check for present components.
223 #
224
225 # Requested by the user.
226
227 .if defined(WANT_LUA) && defined(BEFOREPORTMK)
228 _WANT_LUA=                              ${WANT_LUA}
229 .endif
230
231 # Used for autodetection of installed versions.
232
233 .if defined(_LUA_Need_Version)
234 _WANT_LUA=                              yes
235 .endif
236
237 .if defined(_WANT_LUA)
238 .       undef _HAVE_LUA
239 .       for __WANT_LUA in ${_WANT_LUA}
240 # Check if _WANT_LUA contains more than one word.
241 .               if defined(_HAVE_LUA)
242 IGNORE?=                                selected multiple values for WANT_LUA: ${_WANT_LUA}
243 .               endif
244 _HAVE_LUA=                              #
245 # Check for all versions.
246 .               if ${_WANT_LUA:tl} == "yes"
247 .                       for comp in ${_LUA_COMPS_ALL}
248 .                               for ver in ${_LUA_VERS_ALL}
249 _LUA_COMP=                              _LUA_FILE_${comp}_${ver}
250 .                                       if defined(${_LUA_COMP}) && exists(${${_LUA_COMP}})
251 _HAVE_LUA+=                             ${comp}-${ver}
252 .                                       endif
253 .                               endfor
254 .                       endfor
255 # Check for a specific version.
256 .               elif ${_LUA_VERS_ALL:M${__WANT_LUA}} != ""
257 .                       for comp in ${_LUA_COMPS_ALL}
258 .                               if exists(${_LUA_FILE_${comp}_${__WANT_LUA}})
259 _HAVE_LUA+=                             ${comp}
260 .                               endif
261 .                       endfor
262 .               else
263 IGNORE?=                                selected an invalid value for WANT_LUA: ${__WANT_LUA}
264 .               endif
265 .       endfor
266 .endif          # _WANT_LUA
267
268 # Requested by the user.
269
270 .if defined(WANT_LUA) && defined(BEFOREPORTMK)
271 HAVE_LUA:=                              ${_HAVE_LUA}
272 .endif
273
274 # Used for autodetection of installed versions.
275
276 .if defined(_LUA_Need_Version)
277 _LUA_VER_INSTALLED:=    ${_HAVE_LUA:Mlua-*:S/lua-//}
278 .endif
279
280 #
281 # Select Lua version.
282 #
283
284 .if defined(_LUA_Need_Version)
285 _LUA_Version_Done=              yes
286
287 #
288 # Basic component parsing (ignores dependency types).
289 #
290 # The variables used are:
291 # _LUA_COMP                             - Component part.
292 # _LUA_COMPS_FINAL              - Final list of components.
293 #
294
295 # Detect duplicated components.
296
297 _LUA_COMPS_FINAL=               #
298 .for comp in ${LUA_COMPS}
299 _LUA_COMP=                              ${comp:C/:([[:alpha:]]+)$//}
300 .       for __LUA_COMP in ${_LUA_COMP}
301 .               if ${_LUA_COMPS_ALL:M${__LUA_COMP}} == ""
302 IGNORE?=                                selected an invalid Lua component: ${__LUA_COMP}
303 .               endif
304 .       endfor
305 .       for newcomp in ${_LUA_COMP}
306 .               if ${_LUA_COMPS_FINAL:M${newcomp}} == ""
307 _LUA_COMPS_FINAL+=              ${newcomp}
308 .               endif
309 .       endfor
310 .endfor
311
312 # Set defaults (if one isn't present).
313
314 USE_LUA?=                               ${_LUA_VERS_ALL}
315 USE_LUA_NOT?=                   #
316
317 #
318 # Make lists of valid and invalid versions.
319 #
320 # The following variables are used:
321 # _LUA_VER_CHECK                - If the version is a single one, express in a range.
322 # _LUA_VER_MIN                  - Lower version of the range.
323 # _LUA_VER_MAX                  - Higher version of the range.
324 # _LUA_VER_LIST                 - List of requested versions.
325 # _LUA_VER_NOT_LIST             - List of disallowed versions.
326 # _LUA_VER_FINAL                - List of requested version without disallowed ones.
327 #
328
329 .for list in VER VER_NOT
330 _LUA_${list}_LIST=              #
331 .       for ver in ${USE_LUA${list:C/VER//}}
332 _LUA_VER_CHECK:=                ${ver:C/^([[:digit:]]+(\.[[:digit:]]+)*)$/\1-\1/}
333 _LUA_VER_MIN:=                  ${_LUA_VER_CHECK:C/([[:digit:]]+(\.[[:digit:]]+)*)[-+].*/\1/}
334 _LUA_VER_MAX:=                  ${_LUA_VER_CHECK:C/.*-([[:digit:]]+(\.[[:digit:]]+)*)/\1/}
335 # Minimum version not specified.
336 .               if ${_LUA_VER_MIN} == ${_LUA_VER_CHECK}
337 .                       undef _LUA_VER_MIN
338 .                       for v in ${_LUA_VERS_ALL}
339 _LUA_VER_MIN?=                  ${v}
340 .                       endfor
341 .               endif
342 # Maximum version not specified.
343 .               if ${_LUA_VER_MAX} == ${_LUA_VER_CHECK}
344 .                       for v in ${_LUA_VERS_ALL}
345 _LUA_VER_MAX=                   ${v}
346 .                       endfor
347 .               endif
348 # Expand versions and add valid ones to each list.
349 .               for v in ${_LUA_VERS_ALL}
350 .                       if ${_LUA_VER_MIN} <= ${v} && ${_LUA_VER_MAX} >= ${v} && \
351                            ${_LUA_${list}_LIST:M${v}} == ""
352 _LUA_${list}_LIST+=             ${v}
353 .                       endif
354 .               endfor
355 .       endfor
356 .endfor
357
358 # Merge the lists into a single list of valid versions.
359
360 _LUA_VER_FINAL=                 #
361 .for ver in ${_LUA_VER_LIST}
362 .       if ${_LUA_VER_NOT_LIST:M${ver}} == ""
363 _LUA_VER_FINAL+=                ${ver}
364 .       endif
365 .endfor
366
367 # Remove unusable installed versions.
368
369 .for ver in ${_LUA_VER_INSTALLED}
370 .       if ${_LUA_VER_FINAL:M${ver}} == ""
371 _LUA_VER_INSTALLED:=    ${_LUA_VER_INSTALLED:N${ver}}
372 .       endif
373 .endfor
374
375 # Check for a null version.
376
377 .if empty(_LUA_VER_FINAL)
378 IGNORE?=                                selected a null or invalid Lua version
379 .endif
380
381 # Avoid versions which have unavailable components.
382
383 .for ver in ${_LUA_VER_FINAL}
384 .       for comp in ${_LUA_COMPS_FINAL}
385 .               if !defined(_LUA_PORT_${comp}_${ver})
386 _LUA_WRONG_COMPS+=              ${comp}
387 _LUA_WRONG_VERS+=               ${ver}
388 _LUA_VER_FINAL:=                ${_LUA_VER_FINAL:N${ver}}
389 .               endif
390 .       endfor
391 .endfor
392
393 .if empty(_LUA_VER_FINAL)
394 IGNORE?=                                selected Lua versions (${_LUA_WRONG_VERS}) which do not have the selected components (${_LUA_WRONG_COMPS})
395 .endif
396
397 #
398 # Choose final version.
399 #
400
401 #
402 # Check for the following (in order):
403 # 1) WITH_LUA_VER               - User preference.
404 # 2) WANT_LUA_VER               - Port preference.
405 # 3) _LUA_VER_INSTALLED - Installed versions.
406 # 4) _LUA_VER_FINAL             - Available versions.
407 #
408
409 .for list in _LUA_VER_FINAL ${_LUA_VERS_LISTS}
410 .       if defined(${list})
411 .               for ver in ${${list}}
412 .                       if ${_LUA_VER_FINAL:M${ver}} != ""
413 _LUA_VER=                               ${ver}
414 .                       endif
415 .               endfor
416 .       endif
417 .endfor
418
419 #
420 # Set variables.
421 #
422
423 # Version.
424 LUA_VER?=                               ${_LUA_VER}
425 LUA_VER_SH?=                    ${LUA_VER:C/[[:digit:]]\.([[:digit:]])/\1/}
426 LUA_VER_STR?=                   ${LUA_VER:S/.//g}
427
428 # Package name.
429 LUA_PKGNAMEPREFIX?=             lua${LUA_VER_STR}-
430 LUA_SUBDIR?=                    lua${LUA_VER_STR}
431
432 # Currently Lua ports (those which install Lua and modules) must either:
433 # 1. Have PORTNAME=lua and LATEST_LINK=${LUA_SUBDIR} (currently Lua ports).
434 # 2. Have PKGNAMEPREFIX=${LUA_PKGNAMEPREFIX} (currently Lua modules).
435 # 3. Have LUA_PREFIX?=${PREFIX} (currently none).
436 #
437 # FIXME: the correct solution to this problem could be either:
438 # 1. Create a lua*-config script, and make dependent ports use it.
439 # 2. Set in each port if it's a "Lua module", or just requires Lua.
440 #
441
442 .if (defined(PKGNAMEPREFIX) && ${PKGNAMEPREFIX} == ${LUA_PKGNAMEPREFIX}) || \
443     (${PORTNAME} == "lua" && defined(LATEST_LINK) && \
444     ${LATEST_LINK} == ${LUA_SUBDIR})
445 # For Lua and modules, which need to install in LUA_*DIR, respect PREFIX.
446 LUA_PREFIX?=                    ${PREFIX}
447 .else
448 # For dependencies using LUA_{INC,LIB}DIR, use LOCALBASE as expected.
449 LUA_PREFIX?=                    ${LOCALBASE}
450 .endif
451
452 # Paths.
453 LUA_BINDIR?=                    ${LUA_PREFIX}/bin/${LUA_SUBDIR}
454 LUA_INCDIR?=                    ${LUA_PREFIX}/include/${LUA_SUBDIR}
455 LUA_LIBDIR?=                    ${LUA_PREFIX}/lib/${LUA_SUBDIR}
456 LUA_MODLIBDIR?=                 ${LUA_PREFIX}/lib/lua/${LUA_VER}
457 LUA_MODSHAREDIR?=               ${LUA_PREFIX}/share/lua/${LUA_VER}
458
459 # Programs.
460 LUA_CMD?=                               ${LUA_PREFIX}/bin/lua-${LUA_VER}
461 LUAC_CMD?=                              ${LUA_PREFIX}/bin/luac-${LUA_VER}
462 TOLUA_CMD?=                             ${LUA_PREFIX}/bin/tolua-${LUA_VER}
463 TOLUAXX_CMD?=                   ${LUA_PREFIX}/bin/tolua++-${LUA_VER}
464
465 .endif          # _LUA_Need_Version
466
467 #
468 # Process components list and add dependencies, variables, etc.
469 #
470
471 .if defined(_POSTMKINCLUDED)
472
473 #
474 # Component parsing.
475 #
476 # The variables used are:
477 # _LUA_COMP                             - Component part.
478 # _LUA_DEP_TYPE                 - Dependency type part.
479 # _LUA_COMP_NEW                 - Component + dependency type.
480 # _LUA_COMPS_FINAL              - Final list of components with dependency types.
481 #
482
483 # Default components.
484
485 LUA_COMPS?=                             lua
486
487 # Detect invalid and duplicated components.
488
489 _LUA_COMPS_FINAL=               #
490 .for comp in ${LUA_COMPS}
491 _LUA_COMP=                              ${comp:C/:([[:alpha:]]+)$//}
492 .       if ${_LUA_COMP} == ${comp}
493 _LUA_DEP_TYPE=                  ${_LUA_DEPTYPE_${comp}_${_LUA_VER}}
494 .       else
495 _LUA_DEP_TYPE=                  ${comp:C/.+:([[:alpha:]]+)$/\1/}
496 .       endif
497 _LUA_COMP_NEW=                  ${_LUA_COMP}_${_LUA_DEP_TYPE}
498 .       for __LUA_COMP in ${_LUA_COMP}
499 .               if ${_LUA_COMPS_ALL:M${__LUA_COMP}} == ""
500 IGNORE?=                                selected an invalid Lua component: ${__LUA_COMP}
501 .               endif
502 .       endfor
503 .       for __LUA_DEP_TYPE in ${_LUA_DEP_TYPE}
504 .               if ${_LUA_DEP_TYPES_ALL:M${__LUA_DEP_TYPE}} == ""
505 IGNORE?=                                selected an invalid Lua dependency type: ${__LUA_DEP_TYPE}
506 .               endif
507 .       endfor
508 .       if !defined(_LUA_PORT_${_LUA_COMP}_${_LUA_VER})
509 IGNORE?=                                selected a Lua component (${_LUA_COMP}) which is not available for the selected version (${_LUA_VER})
510 .       endif
511 .       for newcomp in ${_LUA_COMP_NEW}
512 .               if ${_LUA_COMPS_FINAL:M${newcomp}} == "" && !defined(IGNORE)
513 _LUA_COMPS_FINAL+=              ${newcomp}
514 .               endif
515 .       endfor
516 .endfor
517
518 # Add dependencies.
519 #
520 # The variable used are:
521 # _LUA_COMP             -               - Component part.
522 # _LUA_DEP_TYPE                 - Dependency type part.
523
524 .for comp in ${_LUA_COMPS_FINAL}
525 _LUA_DEP_TYPE=                  ${comp:C/.+_([[:alpha:]]+)$/\1/}
526 _LUA_COMP=                              ${comp:C/_([[:alpha:]]+)$//}
527 # XXX Need a .for loop here so the variable is expanded before the assignment.
528 .       for comp_part in ${_LUA_COMP}
529 .               if ${_LUA_DEP_TYPE} == "lib"
530 .                       if defined(_LUA_LIB_${comp_part}_${_LUA_VER})
531 LIB_DEPENDS+=                   ${_LUA_LIB_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}}
532 .                       else
533 BUILD_DEPENDS+=                 ${_LUA_FILE_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}}
534 RUN_DEPENDS+=                   ${_LUA_FILE_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}}
535 .                       endif
536 .               else
537 ${_LUA_DEP_TYPE:tu}_DEPENDS+=   ${_LUA_FILE_${comp_part}_${_LUA_VER}}:${PORTSDIR}/${_LUA_PORT_${comp_part}_${_LUA_VER}}
538 .               endif
539 .       endfor
540 .endfor
541
542 # Packaging list variables.
543 .for var in ${_LUA_PLIST_ALL}
544 PLIST_SUB+=                             ${var}="${${var}}"
545 .endfor
546 .for var in ${_LUA_PLIST_DIR_ALL}
547 PLIST_SUB+=                             ${var}="${${var}:S/${LUA_PREFIX}\///}"
548 .endfor
549 .for var in ${_LUA_PLIST_ALL} ${_LUA_PLIST_DIR_ALL}
550 MAKE_ENV+=                              ${var}="${${var}}"
551 .endfor
552
553 .endif          # _POSTMKINCLUDED