Changeset View
Changeset View
Standalone View
Standalone View
head/Mk/Uses/lua.mk
Show All 23 Lines | |||||
# build add dependency to BUILD_DEPENDS instead of LIB_DEPENDS | # build add dependency to BUILD_DEPENDS instead of LIB_DEPENDS | ||||
# run add dependency to RUN_DEPENDS instead of LIB_DEPENDS | # run add dependency to RUN_DEPENDS instead of LIB_DEPENDS | ||||
# | # | ||||
# env define only the LUA_* vars and add them to PLIST_SUB and | # env define only the LUA_* vars and add them to PLIST_SUB and | ||||
# MAKE_ENV, do not add dependencies or other global state | # MAKE_ENV, do not add dependencies or other global state | ||||
# | # | ||||
# core for building Lua itself | # core for building Lua itself | ||||
# | # | ||||
# If more than one version is allowed, then the LUA_DEFAULT version | # If more than one version is allowed, then the LUA_DEFAULT version (as set | ||||
# (as set in DEFAULT_VERSIONS) is chosen if it is allowed, otherwise | # in DEFAULT_VERSIONS) is chosen if it is in the allowed range, otherwise | ||||
# the highest allowed version is chosen. But if "flavors" was requested, | # the closest allowed version to the default is chosen, preferring the | ||||
# and FLAVOR is set, we use that version. | # larger version in case of a tie. | ||||
# | # | ||||
# But if "flavors" was requested, and FLAVOR is set, we use that version | |||||
# exactly. (It is an error to specify a flavor that isn't supported, but | |||||
# that is checked in bsd.port.mk, not here.) | |||||
# | |||||
# LUA_FLAVOR is defined to the desired flavor whether or not "flavors" was | # LUA_FLAVOR is defined to the desired flavor whether or not "flavors" was | ||||
# selected; ports should use this to specify the flavor of dependencies | # selected; ports should use this to specify the flavor of dependencies | ||||
# which are Lua modules or otherwise Lua-flavored. | # which are Lua modules or otherwise Lua-flavored. | ||||
# | # | ||||
# It's not generally expected that applications that embed Lua, or apps | # It's not generally expected that applications that embed Lua, or apps | ||||
# written in Lua, would use USES=lua:flavors. Given that Lua is lightweight | # written in Lua, would use USES=lua:flavors. Given that Lua is lightweight | ||||
# and does not carry around a whole lot of module ecosystem with it, it is | # and does not carry around a whole lot of module ecosystem with it, it is | ||||
# best that application ports simply specify the Lua version or range of | # best that application ports simply specify the Lua version or range of | ||||
# versions that they support, and let the default one or the latest one be | # versions that they support, and let the default one or the latest one be | ||||
# used. However, they should still use LUA_FLAVOR as needed when specifying | # used. However, they should still use LUA_FLAVOR as needed when specifying | ||||
# dependencies. | # dependencies. | ||||
# | # | ||||
# We assume Lua versions can be represented as 2 digits. | |||||
# | |||||
.if !defined(_INCLUDE_USES_LUA_MK) | .if !defined(_INCLUDE_USES_LUA_MK) | ||||
_INCLUDE_USES_LUA_MK= yes | _INCLUDE_USES_LUA_MK= yes | ||||
# When adding a version, please keep the comment in | # When adding a version, please keep the comment in | ||||
# Mk/bsd.default-versions.mk in sync. | # Mk/bsd.default-versions.mk in sync. | ||||
_LUA_VALID_VERSIONS:= 53 52 51 | _LUA_VALID_VERSIONS:= 53 52 51 | ||||
.if defined(_LUA_EXTRA_VER) | .if defined(_LUA_EXTRA_VER) | ||||
_LUA_VALID_VERSIONS+= ${_LUA_EXTRA_VER} | _LUA_VALID_VERSIONS+= ${_LUA_EXTRA_VER} | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | |||||
# | # | ||||
# If no version was specified with any of the ver or ver+ arguments, allow | # If no version was specified with any of the ver or ver+ arguments, allow | ||||
# all versions. | # all versions. | ||||
# | # | ||||
.if empty(_LUA_WANTED_VERSIONS) | .if empty(_LUA_WANTED_VERSIONS) | ||||
_LUA_WANTED_VERSIONS:= ${_LUA_VALID_VERSIONS} | _LUA_WANTED_VERSIONS:= ${_LUA_VALID_VERSIONS} | ||||
.endif | .endif | ||||
# | # The "preferred" version, which must always exist, is defined as the | ||||
# By now, _LUA_WANTED_VERSIONS is the list of valid version numbers that the | # closest value to the default version, preferring higher versions in | ||||
# caller has allowed through. We want to put the default version, if it's in | # case of ties. We find this by constructing values in sequence: | ||||
# the list, first, followed by all other versions in desc order; then the | # VV VV+1 VV-1 VV+2 VV-2 ... | ||||
# first element is the one we want (or the default flavor in the flavor case) | # and then filtering against the allowed versions. The result is the | ||||
# | # final list of "wanted" versions, with the preferred version first. | ||||
_LUA_NUM_ASC:= \ | |||||
${:U:range=99:@_v@${${_v} > ${_LUA_DEFAULT_VERSION}:?${_v}:}@} | |||||
_LUA_NUM_DESC:= \ | |||||
${:U:range=99:[-1..1]:@_v@${${_v} <= ${_LUA_DEFAULT_VERSION}:?${_v}:}@} | |||||
_LUA_NUM_ALL:= \ | |||||
${:U:range=99:@_v@${_LUA_NUM_DESC:[${_v}]} ${_LUA_NUM_ASC:[${_v}]}@} | |||||
_LUA_WANTED_VERSIONS:= \ | _LUA_WANTED_VERSIONS:= \ | ||||
${_LUA_WANTED_VERSIONS:M${_LUA_DEFAULT_VERSION}} \ | ${_LUA_NUM_ALL:@_v@${_LUA_WANTED_VERSIONS:M${_v}}@} | ||||
${_LUA_WANTED_VERSIONS:N${_LUA_DEFAULT_VERSION}:O:u:[-1..1]} | |||||
.if ${_LUA_ARG_FLAVORS} | .if ${_LUA_ARG_FLAVORS} | ||||
. if empty(FLAVORS) | . if empty(FLAVORS) | ||||
FLAVORS= ${_LUA_WANTED_VERSIONS:S/^/lua/} | FLAVORS= ${_LUA_WANTED_VERSIONS:S/^/lua/} | ||||
. endif | . endif | ||||
. if empty(FLAVOR) | . if empty(FLAVOR) | ||||
FLAVOR= ${FLAVORS:[1]} | FLAVOR= ${FLAVORS:[1]} | ||||
. endif | . endif | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |