From a16da9ffddbfea02dea21d3d35d3e78a37f5298d Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 22 Dec 2011 21:26:39 +0000 Subject: [PATCH] Get lua CFLAGS/LIBS from pkg-config when possible Originally committed to SVN as r6109. --- aegisub/Makefile.inc.in | 4 +-- aegisub/configure.in | 35 ++++++++++++++------------ aegisub/m4macros/agi_find_libheader.m4 | 8 +++--- aegisub/src/Makefile | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/aegisub/Makefile.inc.in b/aegisub/Makefile.inc.in index a9d262be4..222e37f06 100644 --- a/aegisub/Makefile.inc.in +++ b/aegisub/Makefile.inc.in @@ -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 ##################### diff --git a/aegisub/configure.in b/aegisub/configure.in index f2b52682a..2bb93ad61 100644 --- a/aegisub/configure.in +++ b/aegisub/configure.in @@ -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])]) -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])) + AS_IF([test -z "$LUA_LIBS"], + [AGI_FIND_LIB([LUA], [lua51 lua-5.1 lua5.1 lua], [])]) -AS_IF([test -z "$LUA_LDFLAGS"], - AGI_FIND_LIB([LUA], [lua51 lua-5.1 lua5.1 lua], [$LUA_LIBDIR])) - -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 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 diff --git a/aegisub/m4macros/agi_find_libheader.m4 b/aegisub/m4macros/agi_find_libheader.m4 index 6e6334844..7d1dea637 100644 --- a/aegisub/m4macros/agi_find_libheader.m4 +++ b/aegisub/m4macros/agi_find_libheader.m4 @@ -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" ]) diff --git a/aegisub/src/Makefile b/aegisub/src/Makefile index e6141c670..120e23ffc 100644 --- a/aegisub/src/Makefile +++ b/aegisub/src/Makefile @@ -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 ##############