Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/lua.mk
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
# We assume Lua versions can be represented as 2 digits. | # 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:= 54 53 52 51 | _LUA_VALID_VERSIONS:= 54 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} | ||||
.endif | . endif | ||||
_LUA_DEFAULT_VERSION:= ${LUA_DEFAULT:S/.//} | _LUA_DEFAULT_VERSION:= ${LUA_DEFAULT:S/.//} | ||||
# args | # args | ||||
_LUA_ARG_FLAVORS:= | _LUA_ARG_FLAVORS:= | ||||
_LUA_ARG_MODULE:= | _LUA_ARG_MODULE:= | ||||
_LUA_ARG_ENV:= | _LUA_ARG_ENV:= | ||||
_LUA_ARG_CORE:= | _LUA_ARG_CORE:= | ||||
.if ${lua_ARGS:Mmodule} | . if ${lua_ARGS:Mmodule} | ||||
_LUA_ARG_FLAVORS:=yes | _LUA_ARG_FLAVORS:=yes | ||||
_LUA_ARG_MODULE:=yes | _LUA_ARG_MODULE:=yes | ||||
.endif | . endif | ||||
.if ${lua_ARGS:Mflavors} | . if ${lua_ARGS:Mflavors} | ||||
_LUA_ARG_FLAVORS:=yes | _LUA_ARG_FLAVORS:=yes | ||||
.endif | . endif | ||||
.if ${lua_ARGS:Mnoflavors} | . if ${lua_ARGS:Mnoflavors} | ||||
_LUA_ARG_FLAVORS:= | _LUA_ARG_FLAVORS:= | ||||
.endif | . endif | ||||
.if ${lua_ARGS:Menv} | . if ${lua_ARGS:Menv} | ||||
_LUA_ARG_ENV:=yes | _LUA_ARG_ENV:=yes | ||||
.endif | . endif | ||||
.if ${lua_ARGS:Mcore} | . if ${lua_ARGS:Mcore} | ||||
_LUA_ARG_CORE:=yes | _LUA_ARG_CORE:=yes | ||||
_LUA_ARG_ENV:=yes | _LUA_ARG_ENV:=yes | ||||
_LUA_ARG_FLAVORS:= | _LUA_ARG_FLAVORS:= | ||||
_LUA_ARG_MODULE:= | _LUA_ARG_MODULE:= | ||||
.endif | . endif | ||||
# core is for building Lua itself, so it overrides all version checks | # core is for building Lua itself, so it overrides all version checks | ||||
.if ${_LUA_ARG_CORE} | . if ${_LUA_ARG_CORE} | ||||
_LUA_WANTED_VERSION:=${lua_ARGS:M[1-9][0-9]:[1]} | _LUA_WANTED_VERSION:=${lua_ARGS:M[1-9][0-9]:[1]} | ||||
. if ${lua_ARGS:M[1-9][0-9]:[#]} != 1 | . if ${lua_ARGS:M[1-9][0-9]:[#]} != 1 | ||||
IGNORE= USES=lua:core must also specify exactly one version number | IGNORE= USES=lua:core must also specify exactly one version number | ||||
# set to avoid spurious errors below | # set to avoid spurious errors below | ||||
_LUA_WANTED_VERSION:=${_LUA_DEFAULT_VERSION} | _LUA_WANTED_VERSION:=${_LUA_DEFAULT_VERSION} | ||||
. endif | . endif | ||||
_LUA_VALID_VERSIONS:=${_LUA_WANTED_VERSION} | _LUA_VALID_VERSIONS:=${_LUA_WANTED_VERSION} | ||||
_LUA_WANTED_VERSIONS:=${_LUA_WANTED_VERSION} | _LUA_WANTED_VERSIONS:=${_LUA_WANTED_VERSION} | ||||
_LUA_DEFAULT_VERSION:=${_LUA_WANTED_VERSION} | _LUA_DEFAULT_VERSION:=${_LUA_WANTED_VERSION} | ||||
.endif # _LUA_ARG_CORE | . endif # _LUA_ARG_CORE | ||||
.if ! ${_LUA_VALID_VERSIONS:M${_LUA_DEFAULT_VERSION}} | . if ! ${_LUA_VALID_VERSIONS:M${_LUA_DEFAULT_VERSION}} | ||||
IGNORE= Invalid lua version ${LUA_DEFAULT} | IGNORE= Invalid lua version ${LUA_DEFAULT} | ||||
.endif | . endif | ||||
# | # | ||||
# Parse a ver+ argument | # Parse a ver+ argument | ||||
# | # | ||||
.if ${lua_ARGS:M??+} | . if ${lua_ARGS:M??+} | ||||
_LUA_MIN_VERSION:= ${lua_ARGS:M??+:S/+//} | _LUA_MIN_VERSION:= ${lua_ARGS:M??+:S/+//} | ||||
_LUA_MAX_VERSION:= 99 | _LUA_MAX_VERSION:= 99 | ||||
.endif | . endif | ||||
# | # | ||||
# Parse a -ver argument | # Parse a -ver argument | ||||
# | # | ||||
.if ${lua_ARGS:M-??} | . if ${lua_ARGS:M-??} | ||||
_LUA_MAX_VERSION:= ${lua_ARGS:M-??:S/-//} | _LUA_MAX_VERSION:= ${lua_ARGS:M-??:S/-//} | ||||
_LUA_MIN_VERSION:= 0 | _LUA_MIN_VERSION:= 0 | ||||
.endif | . endif | ||||
# | # | ||||
# Parse a ver-ver argument | # Parse a ver-ver argument | ||||
# | # | ||||
.if ${lua_ARGS:M??-??} | . if ${lua_ARGS:M??-??} | ||||
_LUA_MIN_VERSION:= ${lua_ARGS:M??-??:C/-.*//} | _LUA_MIN_VERSION:= ${lua_ARGS:M??-??:C/-.*//} | ||||
_LUA_MAX_VERSION:= ${lua_ARGS:M??-??:C/.*-//} | _LUA_MAX_VERSION:= ${lua_ARGS:M??-??:C/.*-//} | ||||
.endif | . endif | ||||
# | # | ||||
# Parse one or more ver arguments | # Parse one or more ver arguments | ||||
# | # | ||||
.if ${lua_ARGS:M[1-9][0-9]} | . if ${lua_ARGS:M[1-9][0-9]} | ||||
. for _v in ${lua_ARGS:M[1-9][0-9]} | . for _v in ${lua_ARGS:M[1-9][0-9]} | ||||
. if ${_LUA_VALID_VERSIONS:M${_v}} | . if ${_LUA_VALID_VERSIONS:M${_v}} | ||||
_LUA_WANTED_VERSIONS+=${_v} | _LUA_WANTED_VERSIONS+=${_v} | ||||
. endif | . endif | ||||
. endfor | . endfor | ||||
. if empty(_LUA_WANTED_VERSIONS) | . if empty(_LUA_WANTED_VERSIONS) | ||||
IGNORE= USES=lua:nn did not find any valid version number | IGNORE= USES=lua:nn did not find any valid version number | ||||
. endif | . endif | ||||
.endif | . endif | ||||
# | # | ||||
# Resolve version ranges. Append anything within the range to the list of | # Resolve version ranges. Append anything within the range to the list of | ||||
# wanted versions. | # wanted versions. | ||||
# | # | ||||
.if defined(_LUA_MIN_VERSION) && defined(_LUA_MAX_VERSION) | . if defined(_LUA_MIN_VERSION) && defined(_LUA_MAX_VERSION) | ||||
. for _v in ${_LUA_VALID_VERSIONS} | . for _v in ${_LUA_VALID_VERSIONS} | ||||
. if ${_LUA_MIN_VERSION} <= ${_v} && ${_LUA_MAX_VERSION} >= ${_v} | . if ${_LUA_MIN_VERSION} <= ${_v} && ${_LUA_MAX_VERSION} >= ${_v} | ||||
_LUA_WANTED_VERSIONS+=${_v} | _LUA_WANTED_VERSIONS+=${_v} | ||||
. endif | . endif | ||||
. endfor | . endfor | ||||
. if empty(_LUA_WANTED_VERSIONS) | . if empty(_LUA_WANTED_VERSIONS) | ||||
IGNORE= USES=lua:xx-yy did not find any valid version | IGNORE= USES=lua:xx-yy did not find any valid version | ||||
. endif | . endif | ||||
.endif | . endif | ||||
# | # | ||||
# 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 | # The "preferred" version, which must always exist, is defined as the | ||||
# closest value to the default version, preferring higher versions in | # closest value to the default version, preferring higher versions in | ||||
# case of ties. We find this by constructing values in sequence: | # case of ties. We find this by constructing values in sequence: | ||||
# VV VV+1 VV-1 VV+2 VV-2 ... | # VV VV+1 VV-1 VV+2 VV-2 ... | ||||
# and then filtering against the allowed versions. The result is the | # and then filtering against the allowed versions. The result is the | ||||
# final list of "wanted" versions, with the preferred version first. | # final list of "wanted" versions, with the preferred version first. | ||||
_LUA_NUM_ASC:= \ | _LUA_NUM_ASC:= \ | ||||
${:U:range=99:@_v@${${_v} > ${_LUA_DEFAULT_VERSION}:?${_v}:}@} | ${:U:range=99:@_v@${${_v} > ${_LUA_DEFAULT_VERSION}:?${_v}:}@} | ||||
_LUA_NUM_DESC:= \ | _LUA_NUM_DESC:= \ | ||||
${:U:range=99:[-1..1]:@_v@${${_v} <= ${_LUA_DEFAULT_VERSION}:?${_v}:}@} | ${:U:range=99:[-1..1]:@_v@${${_v} <= ${_LUA_DEFAULT_VERSION}:?${_v}:}@} | ||||
_LUA_NUM_ALL:= \ | _LUA_NUM_ALL:= \ | ||||
${:U:range=99:@_v@${_LUA_NUM_DESC:[${_v}]} ${_LUA_NUM_ASC:[${_v}]}@} | ${:U:range=99:@_v@${_LUA_NUM_DESC:[${_v}]} ${_LUA_NUM_ASC:[${_v}]}@} | ||||
_LUA_WANTED_VERSIONS:= \ | _LUA_WANTED_VERSIONS:= \ | ||||
${_LUA_NUM_ALL:@_v@${_LUA_WANTED_VERSIONS:M${_v}}@} | ${_LUA_NUM_ALL:@_v@${_LUA_WANTED_VERSIONS:M${_v}}@} | ||||
.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 | ||||
_LUA_WANTED_VERSION:= ${FLAVOR:S/^lua//} | _LUA_WANTED_VERSION:= ${FLAVOR:S/^lua//} | ||||
.else | . else | ||||
_LUA_WANTED_VERSION:= ${_LUA_WANTED_VERSIONS:[1]} | _LUA_WANTED_VERSION:= ${_LUA_WANTED_VERSIONS:[1]} | ||||
.endif | . endif | ||||
# If we're building Lua itself, everything should be in $PREFIX. If | # If we're building Lua itself, everything should be in $PREFIX. If | ||||
# we're building a module or app, then the stuff we're installing goes | # we're building a module or app, then the stuff we're installing goes | ||||
# in $PREFIX but references to Lua itself are in $LOCALBASE. | # in $PREFIX but references to Lua itself are in $LOCALBASE. | ||||
# | # | ||||
# The assumption is the LUA_MOD* directories are where we're going to | # The assumption is the LUA_MOD* directories are where we're going to | ||||
# install (this is common for both modules and apps), and so we also | # install (this is common for both modules and apps), and so we also | ||||
# define LUA_REFMOD* relative to LOCALBASE for use when specifying | # define LUA_REFMOD* relative to LOCALBASE for use when specifying | ||||
# dependencies and so on. | # dependencies and so on. | ||||
.if ${_LUA_ARG_CORE} | . if ${_LUA_ARG_CORE} | ||||
LUA_BASE=${PREFIX} | LUA_BASE=${PREFIX} | ||||
.else | . else | ||||
LUA_BASE=${LOCALBASE} | LUA_BASE=${LOCALBASE} | ||||
.endif | . endif | ||||
LUA_PREFIX=${PREFIX} | LUA_PREFIX=${PREFIX} | ||||
# | # | ||||
# Exported variables | # Exported variables | ||||
# | # | ||||
LUA_VER_STR= ${_LUA_WANTED_VERSION} | LUA_VER_STR= ${_LUA_WANTED_VERSION} | ||||
LUA_VER= ${_LUA_WANTED_VERSION:S/^5/5./} | LUA_VER= ${_LUA_WANTED_VERSION:S/^5/5./} | ||||
Show All 25 Lines | MAKE_ENV+= LUA_MODLIBDIR=${LUA_MODLIBDIR} \ | ||||
LUA_MODDOCSDIR=${LUA_MODDOCSDIR} \ | LUA_MODDOCSDIR=${LUA_MODDOCSDIR} \ | ||||
LUA_INCDIR=${LUA_INCDIR} \ | LUA_INCDIR=${LUA_INCDIR} \ | ||||
LUA_LIBDIR=${LUA_LIBDIR} \ | LUA_LIBDIR=${LUA_LIBDIR} \ | ||||
LUA_VER=${LUA_VER} \ | LUA_VER=${LUA_VER} \ | ||||
LUA_VER_STR=${LUA_VER_STR} | LUA_VER_STR=${LUA_VER_STR} | ||||
# if building a module or Lua itself, or if the port defined LUA_DOCSUBDIR, | # if building a module or Lua itself, or if the port defined LUA_DOCSUBDIR, | ||||
# then define LUA_DOCSDIR and LUA_EXAMPLESDIR too | # then define LUA_DOCSDIR and LUA_EXAMPLESDIR too | ||||
.if ${_LUA_ARG_CORE} || ${_LUA_ARG_MODULE} | . if ${_LUA_ARG_CORE} || ${_LUA_ARG_MODULE} | ||||
LUA_DOCSUBDIR?=${PORTNAME} | LUA_DOCSUBDIR?=${PORTNAME} | ||||
.endif | . endif | ||||
.if !empty(LUA_DOCSUBDIR) | . if !empty(LUA_DOCSUBDIR) | ||||
LUA_DOCSDIR= ${LUA_MODDOCSDIR}/${LUA_DOCSUBDIR} | LUA_DOCSDIR= ${LUA_MODDOCSDIR}/${LUA_DOCSUBDIR} | ||||
LUA_EXAMPLESDIR=${LUA_MODEXAMPLESDIR}/${LUA_DOCSUBDIR} | LUA_EXAMPLESDIR=${LUA_MODEXAMPLESDIR}/${LUA_DOCSUBDIR} | ||||
PLIST_SUB+= LUA_DOCSDIR=${LUA_DOCSDIR:S,^${LUA_PREFIX}/,,} | PLIST_SUB+= LUA_DOCSDIR=${LUA_DOCSDIR:S,^${LUA_PREFIX}/,,} | ||||
PLIST_SUB+= LUA_EXAMPLESDIR=${LUA_EXAMPLESDIR:S,^${LUA_PREFIX}/,,} | PLIST_SUB+= LUA_EXAMPLESDIR=${LUA_EXAMPLESDIR:S,^${LUA_PREFIX}/,,} | ||||
MAKE_ENV+= LUA_DOCSDIR=${LUA_DOCSDIR} | MAKE_ENV+= LUA_DOCSDIR=${LUA_DOCSDIR} | ||||
MAKE_ENV+= LUA_EXAMPLESDIR=${LUA_EXAMPLESDIR} | MAKE_ENV+= LUA_EXAMPLESDIR=${LUA_EXAMPLESDIR} | ||||
.endif | . endif | ||||
.if empty(_LUA_ARG_ENV) | . if empty(_LUA_ARG_ENV) | ||||
. if ${lua_ARGS:Mbuild} | . if ${lua_ARGS:Mbuild} | ||||
BUILD_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} | BUILD_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} | ||||
. endif | . endif | ||||
. if ${lua_ARGS:Mrun} | . if ${lua_ARGS:Mrun} | ||||
RUN_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} | RUN_DEPENDS+= ${LUA_CMD}:lang/lua${LUA_VER_STR} | ||||
. endif | . endif | ||||
. if !${lua_ARGS:Mbuild} && !${lua_ARGS:Mrun} | . if !${lua_ARGS:Mbuild} && !${lua_ARGS:Mrun} | ||||
LIB_DEPENDS+= liblua-${LUA_VER}.so:lang/lua${LUA_VER_STR} | LIB_DEPENDS+= liblua-${LUA_VER}.so:lang/lua${LUA_VER_STR} | ||||
. endif | . endif | ||||
.endif | . endif | ||||
.endif | .endif |