aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4')
-rw-r--r--m4/.gitignore5
-rw-r--r--m4/compiler-features.m4100
-rw-r--r--m4/compiler-flags.m4159
-rw-r--r--m4/developer-mode.m4112
-rw-r--r--m4/doxygen.m462
-rw-r--r--m4/lua.m469
6 files changed, 507 insertions, 0 deletions
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 000000000000..38066ddf7cad
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,5 @@
+libtool.m4
+ltoptions.m4
+ltsugar.m4
+ltversion.m4
+lt~obsolete.m4
diff --git a/m4/compiler-features.m4 b/m4/compiler-features.m4
new file mode 100644
index 000000000000..55ff4f42b261
--- /dev/null
+++ b/m4/compiler-features.m4
@@ -0,0 +1,100 @@
+dnl Copyright 2010 Google Inc.
+dnl All rights reserved.
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are permitted provided that the following conditions are
+dnl met:
+dnl
+dnl * Redistributions of source code must retain the above copyright
+dnl notice, this list of conditions and the following disclaimer.
+dnl * Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl * Neither the name of Google Inc. nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+dnl
+dnl KYUA_REQUIRE_CXX
+dnl
+dnl Ensures the C++ compiler detected by AC_PROG_CXX is present and works.
+dnl The compiler check should be performed here, but it seems like Autoconf
+dnl does not allow it.
+dnl
+AC_DEFUN([KYUA_REQUIRE_CXX], [
+ AC_CACHE_CHECK([whether the C++ compiler works],
+ [atf_cv_prog_cxx_works],
+ [AC_LANG_PUSH([C++])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+ [atf_cv_prog_cxx_works=yes],
+ [atf_cv_prog_cxx_works=no])
+ AC_LANG_POP([C++])])
+ if test "${atf_cv_prog_cxx_works}" = no; then
+ AC_MSG_ERROR([C++ compiler cannot create executables])
+ fi
+])
+
+dnl
+dnl KYUA_ATTRIBUTE_NORETURN
+dnl
+dnl Checks if the current compiler has a way to mark functions that do not
+dnl return and defines ATTRIBUTE_NORETURN to the appropriate string.
+dnl
+AC_DEFUN([KYUA_ATTRIBUTE_NORETURN], [
+ dnl This check is overly simple and should be fixed. For example,
+ dnl Sun's cc does support the noreturn attribute but CC (the C++
+ dnl compiler) does not. And in that case, CC just raises a warning
+ dnl during compilation, not an error.
+ AC_MSG_CHECKING(whether __attribute__((noreturn)) is supported)
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([], [
+#if ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2)
+ return 0;
+#else
+ return 1;
+#endif
+ ])],
+ [AC_MSG_RESULT(yes)
+ value="__attribute__((noreturn))"],
+ [AC_MSG_RESULT(no)
+ value=""]
+ )
+ AC_SUBST([ATTRIBUTE_NORETURN], [${value}])
+])
+
+
+dnl
+dnl KYUA_ATTRIBUTE_UNUSED
+dnl
+dnl Checks if the current compiler has a way to mark parameters as unused
+dnl so that the -Wunused-parameter warning can be avoided.
+dnl
+AC_DEFUN([KYUA_ATTRIBUTE_UNUSED], [
+ AC_MSG_CHECKING(whether __attribute__((__unused__)) is supported)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([
+static void
+function(int a __attribute__((__unused__)))
+{
+}], [
+ function(3);
+ return 0;
+])],
+ [AC_MSG_RESULT(yes)
+ value="__attribute__((__unused__))"],
+ [AC_MSG_RESULT(no)
+ value=""]
+ )
+ AC_SUBST([ATTRIBUTE_UNUSED], [${value}])
+])
diff --git a/m4/compiler-flags.m4 b/m4/compiler-flags.m4
new file mode 100644
index 000000000000..480e5c740a2a
--- /dev/null
+++ b/m4/compiler-flags.m4
@@ -0,0 +1,159 @@
+dnl Copyright 2010 Google Inc.
+dnl All rights reserved.
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are permitted provided that the following conditions are
+dnl met:
+dnl
+dnl * Redistributions of source code must retain the above copyright
+dnl notice, this list of conditions and the following disclaimer.
+dnl * Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl * Neither the name of Google Inc. nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+dnl \file compiler-flags.m4
+dnl
+dnl Macros to check for the existence of compiler flags. The macros in this
+dnl file support both C and C++.
+dnl
+dnl Be aware that, in order to detect a flag accurately, we may need to enable
+dnl strict warning checking in the compiler (i.e. enable -Werror). Some
+dnl compilers, e.g. Clang, report unknown -W flags as warnings unless -Werror is
+dnl selected. This fact would confuse the flag checks below because we would
+dnl conclude that a flag is valid while in reality it is not. To resolve this,
+dnl the macros below will pass -Werror to the compiler along with any other flag
+dnl being checked.
+
+
+dnl Checks for a compiler flag and sets a result variable.
+dnl
+dnl This is an auxiliary macro for the implementation of _KYUA_FLAG.
+dnl
+dnl \param 1 The shell variable containing the compiler name. Used for
+dnl reporting purposes only. C or CXX.
+dnl \param 2 The shell variable containing the flags for the compiler.
+dnl CFLAGS or CXXFLAGS.
+dnl \param 3 The name of the compiler flag to check for.
+dnl \param 4 The shell variable to set with the result of the test. Will
+dnl be set to 'yes' if the flag is valid, 'no' otherwise.
+dnl \param 5 Additional, optional flags to pass to the C compiler while
+dnl looking for the flag in $3. We use this here to pass -Werror to the
+dnl flag checks (unless we are checking for -Werror already).
+AC_DEFUN([_KYUA_FLAG_AUX], [
+ if test x"${$4-unset}" = xunset; then
+ AC_MSG_CHECKING(whether ${$1} supports $3)
+ saved_flags="${$2}"
+ $4=no
+ $2="${$2} $5 $3"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
+ AC_MSG_RESULT(yes)
+ $4=yes,
+ AC_MSG_RESULT(no))
+ $2="${saved_flags}"
+ fi
+])
+
+
+dnl Checks for a compiler flag and appends it to a result variable.
+dnl
+dnl \param 1 The shell variable containing the compiler name. Used for
+dnl reporting purposes only. CC or CXX.
+dnl \param 2 The shell variable containing the flags for the compiler.
+dnl CFLAGS or CXXFLAGS.
+dnl \param 3 The name of the compiler flag to check for.
+dnl \param 4 The shell variable to which to append $3 if the flag is valid.
+AC_DEFUN([_KYUA_FLAG], [
+ _KYUA_FLAG_AUX([$1], [$2], [-Werror], [kyua_$1_has_werror])
+ if test "$3" = "-Werror"; then
+ found=${kyua_$1_has_werror}
+ else
+ found=unset
+ if test ${kyua_$1_has_werror} = yes; then
+ _KYUA_FLAG_AUX([$1], [$2], [$3], [found], [-Werror])
+ else
+ _KYUA_FLAG_AUX([$1], [$2], [$3], [found], [])
+ fi
+ fi
+ if test ${found} = yes; then
+ $4="${$4} $3"
+ fi
+])
+
+
+dnl Checks for a C compiler flag and appends it to a variable.
+dnl
+dnl \pre The current language is C.
+dnl
+dnl \param 1 The name of the compiler flag to check for.
+dnl \param 2 The shell variable to which to append $1 if the flag is valid.
+AC_DEFUN([KYUA_CC_FLAG], [
+ AC_LANG_ASSERT([C])
+ _KYUA_FLAG([CC], [CFLAGS], [$1], [$2])
+])
+
+
+dnl Checks for a C++ compiler flag and appends it to a variable.
+dnl
+dnl \pre The current language is C++.
+dnl
+dnl \param 1 The name of the compiler flag to check for.
+dnl \param 2 The shell variable to which to append $1 if the flag is valid.
+AC_DEFUN([KYUA_CXX_FLAG], [
+ AC_LANG_ASSERT([C++])
+ _KYUA_FLAG([CXX], [CXXFLAGS], [$1], [$2])
+])
+
+
+dnl Checks for a set of C compiler flags and appends them to CFLAGS.
+dnl
+dnl The checks are performed independently and only when all the checks are
+dnl done, the output variable is modified.
+dnl
+dnl \param 1 Whitespace-separated list of C flags to check.
+AC_DEFUN([KYUA_CC_FLAGS], [
+ AC_LANG_PUSH([C])
+ valid_cflags=
+ for f in $1; do
+ KYUA_CC_FLAG(${f}, valid_cflags)
+ done
+ if test -n "${valid_cflags}"; then
+ CFLAGS="${CFLAGS} ${valid_cflags}"
+ fi
+ AC_LANG_POP([C])
+])
+
+
+dnl Checks for a set of C++ compiler flags and appends them to CXXFLAGS.
+dnl
+dnl The checks are performed independently and only when all the checks are
+dnl done, the output variable is modified.
+dnl
+dnl \pre The current language is C++.
+dnl
+dnl \param 1 Whitespace-separated list of C flags to check.
+AC_DEFUN([KYUA_CXX_FLAGS], [
+ AC_LANG_PUSH([C++])
+ valid_cxxflags=
+ for f in $1; do
+ KYUA_CXX_FLAG(${f}, valid_cxxflags)
+ done
+ if test -n "${valid_cxxflags}"; then
+ CXXFLAGS="${CXXFLAGS} ${valid_cxxflags}"
+ fi
+ AC_LANG_POP([C++])
+])
diff --git a/m4/developer-mode.m4 b/m4/developer-mode.m4
new file mode 100644
index 000000000000..9c9118bf1f86
--- /dev/null
+++ b/m4/developer-mode.m4
@@ -0,0 +1,112 @@
+dnl Copyright 2010 Google Inc.
+dnl All rights reserved.
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are permitted provided that the following conditions are
+dnl met:
+dnl
+dnl * Redistributions of source code must retain the above copyright
+dnl notice, this list of conditions and the following disclaimer.
+dnl * Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl * Neither the name of Google Inc. nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+dnl \file developer-mode.m4
+dnl
+dnl "Developer mode" is a mode in which the build system reports any
+dnl build-time warnings as fatal errors. This helps in minimizing the
+dnl amount of trivial coding problems introduced in the code.
+dnl Unfortunately, this is not bullet-proof due to the wide variety of
+dnl compilers available and their different warning diagnostics.
+dnl
+dnl When developer mode support is added to a package, the compilation will
+dnl gain a bunch of extra warning diagnostics. These will NOT be enforced
+dnl unless developer mode is enabled.
+dnl
+dnl Developer mode is enabled when the user requests it through the
+dnl configure command line, or when building from the repository. The
+dnl latter is to minimize the risk of committing new code with warnings
+dnl into the tree.
+
+
+dnl Adds "developer mode" support to the package.
+dnl
+dnl This macro performs the actual definition of the --enable-developer
+dnl flag and implements all of its logic. See the file-level comment for
+dnl details as to what this implies.
+AC_DEFUN([KYUA_DEVELOPER_MODE], [
+ m4_foreach([language], [$1], [m4_set_add([languages], language)])
+
+ AC_ARG_ENABLE(
+ [developer],
+ AS_HELP_STRING([--enable-developer], [enable developer features]),,
+ [if test -d ${srcdir}/.git; then
+ AC_MSG_NOTICE([building from HEAD; developer mode autoenabled])
+ enable_developer=yes
+ else
+ enable_developer=no
+ fi])
+
+ #
+ # The following warning flags should also be enabled but cannot be.
+ # Reasons given below.
+ #
+ # -Wold-style-cast: Raises errors when using TIOCGWINSZ, at least under
+ # Mac OS X. This is due to the way _IOR is defined.
+ #
+
+ try_c_cxx_flags="-D_FORTIFY_SOURCE=2 \
+ -Wall \
+ -Wcast-qual \
+ -Wextra \
+ -Wpointer-arith \
+ -Wredundant-decls \
+ -Wreturn-type \
+ -Wshadow \
+ -Wsign-compare \
+ -Wswitch \
+ -Wwrite-strings"
+
+ try_c_flags="-Wmissing-prototypes \
+ -Wno-traditional \
+ -Wstrict-prototypes"
+
+ try_cxx_flags="-Wabi \
+ -Wctor-dtor-privacy \
+ -Wno-deprecated \
+ -Wno-non-template-friend \
+ -Wno-pmf-conversions \
+ -Wnon-virtual-dtor \
+ -Woverloaded-virtual \
+ -Wreorder \
+ -Wsign-promo \
+ -Wsynth"
+
+ if test ${enable_developer} = yes; then
+ try_werror=yes
+ try_c_cxx_flags="${try_c_cxx_flags} -g -Werror"
+ else
+ try_werror=no
+ try_c_cxx_flags="${try_c_cxx_flags} -DNDEBUG"
+ fi
+
+ m4_set_contains([languages], [C],
+ [KYUA_CC_FLAGS(${try_c_cxx_flags} ${try_c_flags})])
+ m4_set_contains([languages], [C++],
+ [KYUA_CXX_FLAGS(${try_c_cxx_flags} ${try_cxx_flags})])
+])
diff --git a/m4/doxygen.m4 b/m4/doxygen.m4
new file mode 100644
index 000000000000..a9b7222a5b42
--- /dev/null
+++ b/m4/doxygen.m4
@@ -0,0 +1,62 @@
+dnl Copyright 2010 Google Inc.
+dnl All rights reserved.
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are permitted provided that the following conditions are
+dnl met:
+dnl
+dnl * Redistributions of source code must retain the above copyright
+dnl notice, this list of conditions and the following disclaimer.
+dnl * Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl * Neither the name of Google Inc. nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+dnl
+dnl KYUA_DOXYGEN
+dnl
+dnl Adds a --with-doxygen flag to the configure script and, when Doxygen support
+dnl is requested by the user, sets DOXYGEN to the path of the Doxygen binary and
+dnl enables the WITH_DOXYGEN Automake conditional.
+dnl
+AC_DEFUN([KYUA_DOXYGEN], [
+ AC_ARG_WITH([doxygen],
+ AS_HELP_STRING([--with-doxygen],
+ [build documentation for internal APIs]),
+ [],
+ [with_doxygen=auto])
+
+ if test "${with_doxygen}" = yes; then
+ AC_PATH_PROG([DOXYGEN], [doxygen], [])
+ if test -z "${DOXYGEN}"; then
+ AC_MSG_ERROR([Doxygen explicitly requested but not found])
+ fi
+ elif test "${with_doxygen}" = auto; then
+ AC_PATH_PROG([DOXYGEN], [doxygen], [])
+ elif test "${with_doxygen}" = no; then
+ DOXYGEN=
+ else
+ AC_MSG_CHECKING([for doxygen])
+ DOXYGEN="${with_doxygen}"
+ AC_MSG_RESULT([${DOXYGEN}])
+ if test ! -x "${DOXYGEN}"; then
+ AC_MSG_ERROR([Doxygen binary ${DOXYGEN} is not executable])
+ fi
+ fi
+ AM_CONDITIONAL([WITH_DOXYGEN], [test -n "${DOXYGEN}"])
+ AC_SUBST([DOXYGEN])
+])
diff --git a/m4/lua.m4 b/m4/lua.m4
new file mode 100644
index 000000000000..0d075c576210
--- /dev/null
+++ b/m4/lua.m4
@@ -0,0 +1,69 @@
+dnl Copyright 2011 Google Inc.
+dnl All rights reserved.
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are permitted provided that the following conditions are
+dnl met:
+dnl
+dnl * Redistributions of source code must retain the above copyright
+dnl notice, this list of conditions and the following disclaimer.
+dnl * Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl * Neither the name of Google Inc. nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+dnl
+dnl KYUA_LUA
+dnl
+dnl Helper macro to detect Lua in a variety of systems.
+dnl
+AC_DEFUN([KYUA_LUA], [
+ lua_found=no
+
+ for lua_release in 5.2 5.1; do
+ if test "${lua_found}" = no; then
+ PKG_CHECK_MODULES([LUA], [lua${lua_release} >= ${lua_release}],
+ [lua_found=yes], [true])
+ fi
+ if test "${lua_found}" = no; then
+ PKG_CHECK_MODULES([LUA], [lua-${lua_release} >= ${lua_release}],
+ [lua_found=yes], [true])
+ fi
+ if test "${lua_found}" = no; then
+ PKG_CHECK_MODULES([LUA], [lua >= ${lua_release}],
+ [lua_found=yes], [true])
+ fi
+
+ test "${lua_found}" = no || break
+ done
+
+ if test "${lua_found}" = no; then
+ AC_PATH_PROGS([LUA_CONFIG], [lua-config], [unset])
+ if test "${LUA_CONFIG}" != unset; then
+ AC_SUBST([LUA_CFLAGS], [$(${LUA_CONFIG} --include)])
+ AC_SUBST([LUA_LIBS], [$(${LUA_CONFIG} --libs)])
+ lua_found=yes
+ fi
+ fi
+
+ if test "${lua_found}" = no; then
+ AC_MSG_ERROR([lua (5.1 or newer) is required])
+ else
+ AC_MSG_NOTICE([using LUA_CFLAGS = ${LUA_CFLAGS}])
+ AC_MSG_NOTICE([using LUA_LIBS = ${LUA_LIBS}])
+ fi
+])