summaryrefslogtreecommitdiff
path: root/lang/lua/luaversion.mk
blob: 5e79b6fdc7420133607c934399e4f9a505601bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# $NetBSD: luaversion.mk,v 1.9 2015/02/16 10:52:34 jperkin Exp $

# This file determins which Lua version is used as a dependency for
# a package.
#
# === User-settable variables ===
#
# LUA_VERSION_DEFAULT
#	The preferred lua version to use.
#
#	Possible values: 51 52 53
#	Default: 52
#
# === Infrastructure variables ===
#
# LUA_VERSION_REQD
#	Lua version to use. This variable should not be set by
#	packages; it is ordinarily set by multiversion builds.
#
#	Possible values: ${LUA_VERSIONS_ACCEPTED}
#	Default: ${LUA_VERSION_DEFAULT}
#
# === Package-settable variables ===
#
# LUA_VERSIONS_ACCEPTED
#	The Lua versions that the package can build against. Order
#	is significant; those listed earlier are preferred over those
#	listed later.
#
#	Possible values: 51 52 53
#	Default: 52 53 51
#
# LUA_VERSIONS_INCOMPATIBLE
#	The Lua versions that the package *cannot* build against.
#
#	Possible values: 51 52 53
#	Default: <empty>
#
# LUA_SELF_CONFLICT
#	If set to "yes", CONFLICTS entries are added among the various
#	per-Lua-version variants of a multiversion package.
#
# === Defined variables ===
#
# LUA_PKGPREFIX
#	The prefix to use in PKGNAME for multiversion packages.
#
#	Example: lua51
#
# LUA_INCDIR
#	Relative path to include files.
#
#	Example: include/lua-51
#
# LUA_INTERPRETER
#	Full path to Lua interpreter.
#
# LUA_COMPILER
#	Full path to Lua bytecode compiler (luac).
#
# Keywords: Lua
#

.if !defined (LUA_LUAVERSION_MK)
LUA_LUAVERSION_MK=	# defined

# derive a Lua version from the package name if possible
# optionally handled quoted package names
.if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mlua[0-9][0-9]-*) || \
    defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-lua[0-9][0-9]-*)
LUA_VERSION_REQD?= ${PKGNAME_REQD:C/(^.*-|^)lua([0-9][0-9])-.*/\2/}
.elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mlua[0-9][0-9]-*) || \
    defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-lua[0-9][0-9]-*)
LUA_VERSION_REQD?= ${PKGNAME_OLD:C/(^.*-|^)lua([0-9][0-9])-.*/\2/}
.endif

.include "../../mk/bsd.prefs.mk"

BUILD_DEFS+=		LUA_VERSION_DEFAULT
BUILD_DEFS_EFFECTS+=	LUA_PACKAGE

LUA_VERSION_DEFAULT?=	52
LUA_VERSIONS_ACCEPTED?=	52 53 51
LUA_VERSIONS_INCOMPATIBLE?=# empty

#
# Resolve LUA_VERSIONS_INCOMPATBLE and generate the _OK vars.
#
.for v in ${LUA_VERSIONS_ACCEPTED}
.if empty(LUA_VERSIONS_INCOMPATIBLE:M${v})
_LUA_VERSION_${v}_OK=		yes
_LUA_VERSIONS_ACCEPTED+=	${v}
.endif
.endfor

# Pick a version
.if defined(LUA_VERSION_REQD)
.  if defined(_LUA_VERSION_${LUA_VERSION_REQD}_OK)
_LUA_VERSION=		${LUA_VERSION_REQD}
.  endif
.else
.  if defined(_LUA_VERSION_${LUA_VERSION_DEFAULT}_OK)
_LUA_VERSION?=		${LUA_VERSION_DEFAULT}
.  endif
.  for v in ${_LUA_VERSIONS_ACCEPTED}
.    if defined(_LUA_VERSION_${v}_OK)
_LUA_VERSION?=		${v}
.    endif
.  endfor
.endif

#
# Enable multiversion builds.
#
MULTI+=	LUA_VERSION_REQD=${_LUA_VERSION}

# In case nothing matched
_LUA_VERSION?=		none

#
# Handle self-conflicts
#
.if defined(LUA_SELF_CONFLICT) && !empty(LUA_SELF_CONFLICT:M[Yy][Ee][Ss])
.for v in ${_LUA_VERSIONS_ACCEPTED:N${_LUA_VERSION}}
CONFLICTS+=	${PKGNAME:S/lua${_LUA_VERSION}/lua${v}/:C/-[0-9].*$/-[0-9]*/}
.endfor
.endif

.if ${_LUA_VERSION} == "52"
LUA_PACKAGE=		lua52
LUA_PKGSRCDIR=		../../lang/lua52
LUA_PKGPREFIX=		lua52
LUA_BASEDEPENDS=	lua52>=5.2<5.3:${LUA_PKGSRCDIR}

.elif ${_LUA_VERSION} == "53"
LUA_PACKAGE=		lua53
LUA_PKGSRCDIR=		../../lang/lua53
LUA_PKGPREFIX=		lua53
LUA_BASEDEPENDS=	lua53>=5.3<5.4:${LUA_PKGSRCDIR}

.elif ${_LUA_VERSION} == "51"
LUA_PACKAGE=		lua51
LUA_PKGSRCDIR=		../../lang/lua51
LUA_PKGPREFIX=		lua51
LUA_BASEDEPENDS=	lua51>=5.1<5.2:${LUA_PKGSRCDIR}

.else
PKG_FAIL_REASION+=	"No valid Lua version found"

.endif

#LUA_DEPENDS=	${BUILDLINK_API_DEPENDS.${LUA_PACKAGE}}:${LUA_PKGSRCDIR}

.include "${LUA_PKGSRCDIR}/version.mk"
_LUA_DOT_VERSION=	${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}

LUA_INCDIR=		include/lua-${_LUA_DOT_VERSION}
LUA_INTERPRETER=	${LOCALBASE}/bin/lua${_LUA_DOT_VERSION}
LUA_COMPILER=		${LOCALBASE}/bin/luac${_LUA_DOT_VERSION}

.endif  # LUA_LUAVERSION_MK