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.
This commit is contained in:
Dennis Schridde 2012-10-02 15:42:05 +02:00
parent 30280bcc50
commit 6034750db3
2 changed files with 65 additions and 16 deletions

View File

@ -21,24 +21,55 @@ if test x${A2X} = xno ; then
fi fi
### ###
# Checks for lua # 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])
])
])
])
AC_PATH_PROGS([LUA], [lua5.1 lua51 lua], [no]) # Try versioned Lua 5.2 first
if test x${LUA} = xno ; then PKG_CHECK_MODULES([LUA52], [lua5.2],,[
AC_MSG_ERROR([Program 'lua' is required]) 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 fi
AC_PATH_PROGS([LUAC], [luac5.1 luac51 luac], [no]) AX_SUBST_L([LUA_CFLAGS], [LUA_LIBS], [LUA], [LUAC])
if test x${LUAC} = xno ; then
AC_MSG_ERROR([Program 'luac' is required])
fi
### ###
# Checks for header files. # Checks for header files.
@ -75,4 +106,7 @@ AM_CONDITIONAL([FSEVENTS],
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_OUTPUT AC_OUTPUT
AC_MSG_NOTICE([
Summary:
Using Lua ${LUA_VERSION}
])

15
m4/ax_subst_l.m4 Normal file
View File

@ -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__)])
])