Get lua CFLAGS/LIBS from pkg-config when possible

Originally committed to SVN as r6109.
This commit is contained in:
Thomas Goyne 2011-12-22 21:26:39 +00:00
parent d02cf5c99f
commit a16da9ffdd
4 changed files with 26 additions and 23 deletions

View file

@ -101,7 +101,6 @@ CFLAGS_PTHREAD = @PTHREAD_CFLAGS@
CFLAGS_LIBPULSE = @LIBPULSE_CFLAGS@
CFLAGS_UCHARDET = -I../universalchardet
LDFLAGS_LUA = @LUA_LDFLAGS@
LIBS_ALSA = @ALSA_LIBS@
LIBS_FFMS2 = @FFMS2_LIBS@
LIBS_FFTW3 = @FFTW3_LIBS@
@ -112,10 +111,11 @@ LIBS_HUNSPELL = @HUNSPELL_LIBS@
LIBS_ICONV = @ICONV_LIBS@
LIBS_LIBASS = @LIBASS_LIBS@
LIBS_LIBCURL = @LIBCURL_LIBS@
LIBS_LIBPULSE = @LIBPULSE_LIBS@
LIBS_LUA = @LUA_LIBS@
LIBS_OPENAL = @OPENAL_LIBS@
LIBS_PORTAUDIO = @PORTAUDIO_LIBS@
LIBS_PTHREAD = @PTHREAD_LIBS@
LIBS_LIBPULSE = @LIBPULSE_LIBS@
LIBS_UCHARDET ?= ../universalchardet/libuniversalchardet.a
#####################

View file

@ -429,20 +429,20 @@ AC_ARG_WITH(lua,
AS_HELP_STRING([--without-lua],
[build without lua 5.1 (auto4)]))
AC_ARG_VAR([LUA_CFLAGS], [CFLAGS to use for LUA 5.1 [autodetect]])
AC_ARG_VAR([LUA_LDFLAGS], [LDFLAGS to use for LUA 5.1 [autodetect]])
AC_ARG_VAR([LUA_LIBDIR], [Location of LUA 5.1 library. [none]])
AS_IF([test x$with_lua = xno], [$with_auto4_lua="no"; lua_disabled="(disabled)"], [
# First try pkg-config with several names
PKG_CHECK_MODULES(LUA, lua >= 5.1, [with_auto4_lua="yes"], [
PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [with_auto4_lua="yes"], [
PKG_CHECK_MODULES(LUA, lua-5.1 >= 5.1, [with_auto4_lua="yes"], [
# Still not found so try to autodetect
AS_IF([test -z "$LUA_CFLAGS"],
AGI_FIND_HEADER([LUA], [lua.hpp], [/usr/include/lua5.1 /usr/include/lua51 /usr/local/include/lua51 /usr/local/include/lua5.1 /usr/include /usr/local/include]))
[AGI_FIND_HEADER([LUA], [lua.hpp],
[/usr/include/lua5.1 /usr/include/lua51 /usr/local/include/lua51 /usr/local/include/lua5.1 /usr/include /usr/local/include])])
AS_IF([test -z "$LUA_LDFLAGS"],
AGI_FIND_LIB([LUA], [lua51 lua-5.1 lua5.1 lua], [$LUA_LIBDIR]))
AS_IF([test -z "$LUA_LIBS"],
[AGI_FIND_LIB([LUA], [lua51 lua-5.1 lua5.1 lua], [])])
aegisub_save_LIBS="$LIBS"
LIBS="$LUA_LDFLAGS"
AS_IF([test x$with_lua = xno], [lua_disabled="(disabled)"], [
AC_AGI_COMPILE([Lua 5.1 (auto4)], [lua], [$LUA_CFLAGS], [],[
AC_AGI_COMPILE([Lua 5.1 (auto4)], [lua], [$LUA_CFLAGS], [$LUA_LIBS],[
#include <lua.hpp>
int main () {
@ -451,15 +451,18 @@ int main () {
int res = lua_objlen(L, -1) == 4;
lua_close(L);
return !res;
}])])
LIBS="$aegisub_save_LIBS"
}])
AS_IF([test x$agi_cv_with_lua = xno && test x$with_lua = xyes],
[AC_MSG_FAILURE([--with-lua was specified, but lua could not be found. Try setting LUA_CLFAGS and LUA_LIBS manually])])
with_auto4_lua=$agi_cv_with_lua
])])])
])
with_auto4_lua=${agi_cv_with_lua:-no}
AS_IF([test x$with_auto4_lua = xyes], AC_DEFINE(WITH_AUTO4_LUA, 1, [Enable Automation (auto4), requires lua]))
AC_SUBST(with_auto4_lua)
AC_SUBST(LUA_CFLAGS)
AC_SUBST(LUA_LDFLAGS)
AC_SUBST(LUA_LIBS)
################
# Widget support

View file

@ -28,7 +28,7 @@ AC_DEFUN([AGI_FIND_HEADER],[
AC_DEFUN([AGI_FIND_LIB],[
aegisub_save_LDFLAGS="$LDFLAGS"
aegisub_save_LIBS="$LIBS"
if test -n "$3"; then
LDDIR="-L$3"
@ -36,7 +36,7 @@ AC_DEFUN([AGI_FIND_LIB],[
for lib in $2; do
vlib=`echo $lib | $as_tr_sh`
LDFLAGS="$LDDIR -l$lib"
LIBS="$LDDIR -l$lib"
AC_CACHE_CHECK(
[for -l${lib}],
[agi_cv_lib_${vlib}],
@ -52,7 +52,7 @@ AC_DEFUN([AGI_FIND_LIB],[
done
if test -n "$found"; then
$1_LDFLAGS="$LDDIR -l$found"
$1_LIBS="$LDDIR -l$found"
fi
LDFLAGS="$aegisub_save_LDFLAGS"
LIBS="$aegisub_save_LIBS"
])

View file

@ -79,7 +79,7 @@ endif
ifeq (yes, $(HAVE_AUTO4_LUA))
SRC_OPT += auto4_lua.cpp auto4_lua_assfile.cpp auto4_lua_dialog.cpp auto4_lua_progresssink.cpp auto4_lua_scriptreader.cpp
auto4_lua.o auto4_lua_assfile.o auto4_lua_dialog.o auto4_lua_progresssink.o auto4_lua_scriptreader.o: CXXFLAGS += $(CFLAGS_LUA)
LDFLAGS += $(LDFLAGS_LUA)
LIBS += $(LIBS_LUA)
endif
##############