1 # Find highest known lua version.
3 # It uses pkg-config to do this, but will fail if you have liblua, but
4 # not the corresponding interpreter/compiler. Let's say you have liblua5.2
5 # but want to build with liblua5.1 (for which you have the lib, interpreter
6 # and compiler), you can override by setting LUA_VERSION=5.0 when invoking
9 # If successful, sets the following variables:
10 # * LUA_VERSION (unless already set)
11 # * LUA_LIBS (can be appended to LDFLAGS directly)
12 # * LUA_INCLUDES (can be appended to CFLAGS directly)
13 # * LUA (full path to lua interpreter)
14 # * LUAC (full path to lua compiler)
16 LUA_VERSIONS_CANDIDATES
= $(or
$(LUA_VERSION
),5.2 5.1 5.0)
18 LUA_PKG
:= $(firstword $(foreach ver
,$(LUA_VERSIONS_CANDIDATES
),$(shell \
19 ($(PKG_CONFIG
) --exists lua-
$(ver
) && echo lua-
$(ver
)) \
20 ||
($(PKG_CONFIG
) --exists lua
$(ver
:5.0=) && echo lua
$(ver
:5.0=)))))
23 $(error Could not find
$(or
$(LUA_VERSION
),any
) lua version.
(Did you
install the
-dev package?
))
26 LUA_VERSION ?
= $(or
$(shell $(PKG_CONFIG
) --variable
=V
$(LUA_PKG
)),5.0)
28 # prior to 5.1 the lib didn't include version in name.
29 LUA_SUFFIX
:= $(if
$(findstring $(LUA_VERSION
),5.0),,$(LUA_VERSION
))
31 LUA_LIBS
:= $(or
$(shell $(PKG_CONFIG
) --libs
$(LUA_PKG
)), $(error
"pkg-config couldn't find linker flags for lua$(LUA_SUFFIX)!"))
32 LUA_INCLUDES
:= $(shell $(PKG_CONFIG
) --cflags $(LUA_PKG
))
33 LUA
:= $(or
$(shell which lua
$(LUA_SUFFIX
)), $(shell which lua
), $(error No lua
$(LUA_SUFFIX
) interpreter found
!))
34 LUAC
:= $(or
$(shell which luac
$(LUA_SUFFIX
)), $(shell which luac
), $(error No lua
$(LUA_SUFFIX
) compiler found
!))