From 6034750db34c52f08f39412c9ba60f193e8fb7c4 Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Tue, 2 Oct 2012 15:42:05 +0200 Subject: [PATCH] Try harder to find matching Lua program/library pairs Uses an AX_SUBST_L macro I copied from another project of mine. Originally found somewhere on the net. --- configure.ac | 66 ++++++++++++++++++++++++++++++++++++------------ m4/ax_subst_l.m4 | 15 +++++++++++ 2 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 m4/ax_subst_l.m4 diff --git a/configure.ac b/configure.ac index d7deb1c..05ce717 100644 --- a/configure.ac +++ b/configure.ac @@ -21,24 +21,55 @@ if test x${A2X} = xno ; then fi ### -# Checks for lua -PKG_CHECK_MODULES([LUA], [lua5.1 >= 5.1.3],,[ -PKG_CHECK_MODULES([LUA], [lua51 >= 5.1.3],,[ -PKG_CHECK_MODULES([LUA], [lua-5.1 >= 5.1.3],,[ -PKG_CHECK_MODULES([LUA], [lua >= 5.1.3]) -]) -]) -]) +# Checks for Lua -AC_PATH_PROGS([LUA], [lua5.1 lua51 lua], [no]) -if test x${LUA} = xno ; then - AC_MSG_ERROR([Program 'lua' is required]) +# Try versioned Lua 5.2 first +PKG_CHECK_MODULES([LUA52], [lua5.2],,[ + PKG_CHECK_MODULES([LUA52], [lua52],,[ + PKG_CHECK_MODULES([LUA52], [lua-5.2],,[:]) + ]) +]) +AC_PATH_PROGS([LUA52], [lua5.2 lua52], [no]) +AC_PATH_PROGS([LUAC52], [luac5.2 luac52], [no]) + +if test -z "${LUA52_PKG_ERRORS}" -a "${LUA52}" != no -a "${LUAC52}" != no ; then + LUA_VERSION="5.2" + LUA_CFLAGS="${LUA52_CFLAGS}" + LUA_LIBS="${LUA52_LIBS}" + LUA="${LUA52}" + LUAC="${LUAC52}" +else + # Fall back to versioned Lua 5.1 + PKG_CHECK_MODULES([LUA51], [lua5.1 >= 5.1.3],,[ + PKG_CHECK_MODULES([LUA51], [lua51 >= 5.1.3],,[ + PKG_CHECK_MODULES([LUA51], [lua-5.1 >= 5.1.3],,[:]) + ]) + ]) + AC_PATH_PROGS([LUA51], [lua5.1 lua51], [no]) + AC_PATH_PROGS([LUAC51], [luac5.1 luac51], [no]) + + if test -z "${LUA51_PKG_ERRORS}" -a "${LUA51}" != no -a "${LUAC51}" != no ; then + LUA_VERSION="5.1" + LUA_CFLAGS="${LUA51_CFLAGS}" + LUA_LIBS="${LUA51_LIBS}" + LUA="${LUA51}" + LUAC="${LUAC51}" + else + # Try any Lua now + PKG_CHECK_MODULES([LUA], [lua >= 5.1.3],,[:]) + AC_PATH_PROG([LUA], [lua], [no]) + AC_PATH_PROG([LUAC], [luac], [no]) + + if test -z "${LUA_PKG_ERRORS}" -a "${LUA}" != no -a "${LUAC}" != no ; then + LUA_VERSION="(unknown version)" + else + AC_MSG_ERROR([Need a Lua toolchain with matching versions ('lua' library and 'lua' and 'luac' programs)]) + fi + fi fi -AC_PATH_PROGS([LUAC], [luac5.1 luac51 luac], [no]) -if test x${LUAC} = xno ; then - AC_MSG_ERROR([Program 'luac' is required]) -fi +AX_SUBST_L([LUA_CFLAGS], [LUA_LIBS], [LUA], [LUAC]) + ### # Checks for header files. @@ -75,4 +106,7 @@ AM_CONDITIONAL([FSEVENTS], AC_CONFIG_FILES([Makefile]) AC_OUTPUT - +AC_MSG_NOTICE([ +Summary: + Using Lua ${LUA_VERSION} +]) diff --git a/m4/ax_subst_l.m4 b/m4/ax_subst_l.m4 new file mode 100644 index 0000000..a7095c4 --- /dev/null +++ b/m4/ax_subst_l.m4 @@ -0,0 +1,15 @@ + +# ax_subst_l.m4 - Substitute every var in the given comma seperated list -*-Autoconf-*- +# +# Copyright (C) 2012 Dennis Schridde +# +# This file is free software; the authors give +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 1 + +# Substitute every var in the given comma seperated list +AC_DEFUN([AX_SUBST_L],[ + m4_foreach([__var__], [$@], [AC_SUBST(__var__)]) +])