Browse Source

Make configure not search for dependencies of disabled implementations (resolves #1099)

Also rewrite dependency searching so we have a single file with all test macros.

--HG--
branch : minor
Bart van Strien 9 years ago
parent
commit
e515cf076e
2 changed files with 103 additions and 56 deletions
  1. 26 56
      platform/unix/configure.ac
  2. 77 0
      platform/unix/deps.m4

+ 26 - 56
platform/unix/configure.ac

@@ -19,6 +19,7 @@ AC_LANG([C++])
 
 dnl Workaround for old aclocal versions
 m4_include([platform/unix/cpp11.m4])
+m4_include([platform/unix/deps.m4])
 
 includes=
 
@@ -38,70 +39,41 @@ AS_VAR_IF([enable_osx], [no], [], #else
 
 # --with-lua and --with-luaversion
 AC_ARG_WITH([lua], [AS_HELP_STRING([--with-lua], [Select the lua implementation])],
-			[], [with_lua=luajit])
+	[], [with_lua=luajit])
 AC_ARG_WITH([luaversion], [AS_HELP_STRING([--with-luaversion], [Select the lua version])],
-			[], [with_luaversion=5.1])
+	[], [with_luaversion=5.1])
 
-# pkg-config libraries
-AM_PATH_SDL2([], [], [LOVE_MSG_ERROR([SDL 2])])
 with_clean_luaversion=`printf ${with_luaversion} | sed 's/\.//g'`
-PKG_CHECK_MODULES([lua], [${with_lua}${with_luaversion}], [lua_found=yes],
-	[PKG_CHECK_MODULES([lua], [${with_lua}${with_clean_luaversion}], [lua_found=yes],
-	[PKG_CHECK_MODULES([lua], [${with_lua}], [lua_found=yes], [lua_found=no])])])
-PKG_CHECK_MODULES([freetype2], [freetype2], [], [LOVE_MSG_ERROR([FreeType2])])
-PKG_CHECK_MODULES([openal], [openal], [], [LOVE_MSG_ERROR([OpenAL])])
-PKG_CHECK_MODULES([libmodplug], [libmodplug], [], [LOVE_MSG_ERROR([libmodplug])])
-PKG_CHECK_MODULES([vorbisfile], [vorbisfile], [], [LOVE_MSG_ERROR([libvorbis and libvorbisfile])])
-PKG_CHECK_MODULES([zlib], [zlib], [], [LOVE_MSG_ERROR([zlib])])
-PKG_CHECK_MODULES([theora], [theoradec], [], [LOVE_MSG_ERROR([libtheora])])
-
-# Other libraries
-AC_SEARCH_LIBS([sqrt], [m], [], [LOVE_MSG_ERROR([the C math library])])
-AC_SEARCH_LIBS([PHYSFS_init], [physfs], [], [LOVE_MSG_ERROR([PhysicsFS])])
-
-# Lua, treated seperately because of --with-lua
-AS_VAR_IF([lua_found], [yes],
-		  #if
-		  [
-		   luaheaders_found=yes
-		   AC_MSG_CHECKING([for library containing lua_call])
-		   AC_MSG_RESULT([${lua_LIBS}])],
-		  #else
-		  [
-		   AC_MSG_WARN([Could not find pkg-config definition for ${with_lua}${with_luaversion} or ${with_lua}${with_clean_luaversion}${with_lua}, falling back to manual detection])
-		   AC_SEARCH_LIBS([lua_call], ["${with_lua}${with_luaversion}" "${with_lua}"], [],
-						  [LOVE_MSG_ERROR([$with_lua])])
-		   luaheaders_found=no
-		   AC_CHECK_HEADER(["${with_lua}${with_luaversion}/lua.h"], [luaheaders_found=yes includes="$includes -I/usr/include/${with_lua}${with_luaversion}"], [])
-		   AC_CHECK_HEADER(["${with_lua}/lua.h"], [luaheaders_found=yes includes="$includes -I/usr/include/${with_lua}"], [])])
-AS_VAR_IF([luaheaders_found], [yes], [], #else
-		  [
-		   AC_MSG_WARN([Could not locate lua headers for ${with_lua}${with_luaversion} or ${with_lua}, you probably need to specify them with CPPFLAGS])])
-
-# mpg123, treated seperately because it can be disabled (default on)
-# also not pkg-config because of the FILE_OFFSET_BITS.. bit
+
+# Generated sources for enabling/disabling modules
+m4_include([configure-modules.ac])
+
+# Other features that can be enabled/disabled
 AC_ARG_ENABLE([mpg123], AC_HELP_STRING([--disable-mpg123], [Disable mp3 support, for patent-free builds]), [], [enable_mpg123=yes])
+AC_ARG_ENABLE([gme], AC_HELP_STRING([--enable-gme], [Enable GME support, for more chiptuney goodness]), [], [enable_gme=no])
+
+ACLOVE_DEP_LUA
+ACLOVE_DEP_SDL2
+ACLOVE_DEP_LIBM
+ACLOVE_DEP_ZLIB
+
+AS_VAR_IF([enable_audio_openal], [true], [ACLOVE_DEP_OPENAL], [])
+AS_VAR_IF([enable_filesystem_physfs], [true], [ACLOVE_DEP_PHYSFS], [])
+AS_VAR_IF([enable_font_freetype], [true], [ACLOVE_DEP_FREETYPE2], [])
+AS_VAR_IF([enable_sound_lullaby], [true], [
+	ACLOVE_DEP_LIBMODPLUG
+	ACLOVE_DEP_VORBISFILE
+], [enable_mpg123=no])
+AS_VAR_IF([enable_video_theora], [true], [ACLOVE_DEP_THEORA], [])
+AS_VAR_IF([enable_gme], [yes], [ACLOVE_DEP_GME], [])
 AS_VAR_IF([enable_mpg123], [no],
 	  AC_DEFINE([LOVE_NOMPG123], [], [Build without mpg123]),
-	  # else
-	  AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [],
-					 [LOVE_MSG_ERROR([libmpg123])])
-	  AC_SEARCH_LIBS([mpg123_seek_64], [mpg123],
-					 AC_SUBST([FILE_OFFSET],[-D_FILE_OFFSET_BITS=64]),
-					 AC_SUBST([FILE_OFFSET],[])))
+	  [ACLOVE_DEP_MPG123])
 
 # GME, treated seperately because it can be enabled (default off)
-AC_ARG_ENABLE([gme], AC_HELP_STRING([--enable-gme], [Enable GME support, for more chiptuney goodness]), [], [enable_gme=no])
-AS_VAR_IF([enable_gme], [yes],
-	  AC_SEARCH_LIBS([gme_open_data], [gme], [], [LOVE_MSG_ERROR([gme])])
-	  AC_DEFINE([LOVE_SUPPORT_GME], [], [Enable gme])
-	  AC_CHECK_HEADER([gme/gme.h], [includes="$includes -I/usr/include/gme"], []))
 
 # libenet check for socklen_t
-AC_CHECK_TYPE([socklen_t], [AC_DEFINE([HAS_SOCKLEN_T], [1], [Define if socklen_t exists.] )], , 
-              #include <sys/types.h>
-              #include <sys/socket.h>
-)
+ACLOVE_SOCKLEN_T
 
 # Optionally build the executable (default on)
 AC_ARG_ENABLE([exe],
@@ -122,8 +94,6 @@ AS_VAR_IF([LUA_EXECUTABLE], [:],
 # Set our includes as automake variable
 AC_SUBST([LOVE_INCLUDES], ["$includes"])
 
-m4_include([configure-modules.ac])
-
 AC_CONFIG_FILES([
 	Makefile
 	src/Makefile

+ 77 - 0
platform/unix/deps.m4

@@ -0,0 +1,77 @@
+AC_DEFUN([ACLOVE_DEP_FREETYPE2], [
+	PKG_CHECK_MODULES([freetype2], [freetype2], [], [LOVE_MSG_ERROR([FreeType2])])])
+
+AC_DEFUN([ACLOVE_DEP_OPENAL], [
+	PKG_CHECK_MODULES([openal], [openal], [], [LOVE_MSG_ERROR([OpenAL])])])
+
+AC_DEFUN([ACLOVE_DEP_LIBMODPLUG], [
+	PKG_CHECK_MODULES([libmodplug], [libmodplug], [], [LOVE_MSG_ERROR([libmodplug])])])
+
+AC_DEFUN([ACLOVE_DEP_VORBISFILE], [
+	PKG_CHECK_MODULES([vorbisfile], [vorbisfile], [], [LOVE_MSG_ERROR([libvorbis and libvorbisfile])])])
+
+AC_DEFUN([ACLOVE_DEP_ZLIB], [
+	PKG_CHECK_MODULES([zlib], [zlib], [], [LOVE_MSG_ERROR([zlib])])])
+
+AC_DEFUN([ACLOVE_DEP_THEORA], [
+	PKG_CHECK_MODULES([theora], [theoradec], [], [LOVE_MSG_ERROR([libtheora])])])
+
+AC_DEFUN([ACLOVE_DEP_LIBM], [
+	AC_SEARCH_LIBS([sqrt], [m], [], [LOVE_MSG_ERROR([the C math library])])])
+
+AC_DEFUN([ACLOVE_DEP_PHYSFS], [
+	AC_SEARCH_LIBS([PHYSFS_init], [physfs], [], [LOVE_MSG_ERROR([PhysicsFS])])])
+
+AC_DEFUN([ACLOVE_DEP_SDL2], [
+	AM_PATH_SDL2([], [], [LOVE_MSG_ERROR([SDL 2])])])
+
+# does not use pkg-config because of the FILE_OFFSET_BITS.. bit
+AC_DEFUN([ACLOVE_DEP_MPG123], [
+	AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [],
+		[LOVE_MSG_ERROR([libmpg123])])
+	AC_SEARCH_LIBS([mpg123_seek_64], [mpg123],
+		AC_SUBST([FILE_OFFSET],[-D_FILE_OFFSET_BITS=64]),
+		AC_SUBST([FILE_OFFSET],[]))])
+
+AC_DEFUN([ACLOVE_DEP_GME], [
+	AC_SEARCH_LIBS([gme_open_data], [gme], [], [LOVE_MSG_ERROR([gme])])
+	AC_DEFINE([LOVE_SUPPORT_GME], [], [Enable gme])
+	AC_CHECK_HEADER([gme/gme.h], [includes="$includes -I/usr/include/gme"], [])])
+
+# For enet
+AC_DEFUN([ACLOVE_SOCKLEN_T], [
+	AC_CHECK_TYPE([socklen_t], [AC_DEFINE([HAS_SOCKLEN_T], [1], [Define if socklen_t exists.] )], ,
+		#include <sys/types.h>
+		#include <sys/socket.h>
+	)])
+
+# The lua detection is quite annoying because of distro differences and our version selection code
+AC_DEFUN([ACLOVE_DEP_LUA_PKGCONFIG], [
+	PKG_CHECK_MODULES([lua], [${with_lua}${with_luaversion}], [aclove_lua_found=yes],
+		[PKG_CHECK_MODULES([lua], [${with_lua}${with_clean_luaversion}], [aclove_lua_found=yes],
+			[PKG_CHECK_MODULES([lua], [${with_lua}], [aclove_lua_found=yes], [])])])
+
+	AS_VAR_IF([aclove_lua_found], [yes],
+		[
+			aclove_luaheaders_found=yes
+			AC_MSG_CHECKING([for library containing lua_call])
+			AC_MSG_RESULT([${lua_LIBS}])
+		], [])])
+
+AC_DEFUN([ACLOVE_DEP_LUA_FALLBACK], [
+	AC_MSG_WARN([Could not find pkg-config definition for ${with_lua}${with_luaversion} or ${with_lua}${with_clean_luaversion}${with_lua}, falling back to manual detection])
+	AC_SEARCH_LIBS([lua_call], ["${with_lua}${with_luaversion}" "${with_lua}"], [aclove_lua_found=yes],
+		[LOVE_MSG_ERROR([$with_lua])])
+
+	AC_CHECK_HEADER(["${with_lua}${with_luaversion}/lua.h"], [aclove_luaheaders_found=yes includes="$includes -I/usr/include/${with_lua}${with_luaversion}"], [])
+	AC_CHECK_HEADER(["${with_lua}/lua.h"], [aclove_luaheaders_found=yes includes="$includes -I/usr/include/${with_lua}"], [])])
+
+# First, try pkg-config, then fall back to manual detection if not available.
+AC_DEFUN([ACLOVE_DEP_LUA], [ dnl Requires with-lua and with-luaversion
+	aclove_lua_found=no
+	aclove_luaheaders_found=no
+
+	ACLOVE_DEP_LUA_PKGCONFIG
+	AS_VAR_IF([aclove_lua_found], [no], [ACLOVE_DEP_LUA_FALLBACK], [])
+	AS_VAR_IF([aclove_luaheaders_found], [no],
+		[AC_MSG_WARN([Could not locate lua headers for ${with_lua}${with_luaversion} or ${with_lua}, you probably need to specify them with CPPFLAGS])], [])])