xref: /freebsd/contrib/lutok/m4/lua.m4 (revision 02e9120893770924227138ba49df1edb3896112a)
1dnl Copyright 2011 Google Inc.
2dnl All rights reserved.
3dnl
4dnl Redistribution and use in source and binary forms, with or without
5dnl modification, are permitted provided that the following conditions are
6dnl met:
7dnl
8dnl * Redistributions of source code must retain the above copyright
9dnl   notice, this list of conditions and the following disclaimer.
10dnl * Redistributions in binary form must reproduce the above copyright
11dnl   notice, this list of conditions and the following disclaimer in the
12dnl   documentation and/or other materials provided with the distribution.
13dnl * Neither the name of Google Inc. nor the names of its contributors
14dnl   may be used to endorse or promote products derived from this software
15dnl   without specific prior written permission.
16dnl
17dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29dnl
30dnl KYUA_LUA
31dnl
32dnl Helper macro to detect Lua in a variety of systems.
33dnl
34AC_DEFUN([KYUA_LUA], [
35    lua_found=no
36
37    for lua_release in 5.2 5.1; do
38        if test "${lua_found}" = no; then
39            PKG_CHECK_MODULES([LUA], [lua${lua_release} >= ${lua_release}],
40                              [lua_found=yes], [true])
41        fi
42        if test "${lua_found}" = no; then
43            PKG_CHECK_MODULES([LUA], [lua-${lua_release} >= ${lua_release}],
44                              [lua_found=yes], [true])
45        fi
46        if test "${lua_found}" = no; then
47            PKG_CHECK_MODULES([LUA], [lua >= ${lua_release}],
48                              [lua_found=yes], [true])
49        fi
50
51        test "${lua_found}" = no || break
52    done
53
54    if test "${lua_found}" = no; then
55        AC_PATH_PROGS([LUA_CONFIG], [lua-config], [unset])
56        if test "${LUA_CONFIG}" != unset; then
57            AC_SUBST([LUA_CFLAGS], [$(${LUA_CONFIG} --include)])
58            AC_SUBST([LUA_LIBS], [$(${LUA_CONFIG} --libs)])
59            lua_found=yes
60        fi
61    fi
62
63    if test "${lua_found}" = no; then
64        AC_MSG_ERROR([lua (5.1 or newer) is required])
65    else
66        AC_MSG_NOTICE([using LUA_CFLAGS = ${LUA_CFLAGS}])
67        AC_MSG_NOTICE([using LUA_LIBS = ${LUA_LIBS}])
68    fi
69])
70