--luajit and --lua52 compile options

no longer looks for lua 5.2 unless you tell it to
This commit is contained in:
jacob1 2015-02-13 18:20:52 -05:00
parent 03e07945e3
commit 316d0f1ace
2 changed files with 38 additions and 17 deletions

View File

@ -70,7 +70,8 @@ AddSconsOption('renderer', False, False, "Build the save renderer.")
AddSconsOption('wall', False, False, "Error on all warnings.") AddSconsOption('wall', False, False, "Error on all warnings.")
AddSconsOption('no-warnings', False, False, "Disable all compiler warnings.") AddSconsOption('no-warnings', False, False, "Disable all compiler warnings.")
AddSconsOption('nolua', False, False, "Disable Lua.") AddSconsOption('nolua', False, False, "Disable Lua.")
AddSconsOption('luajit', False, False, "Enable LuaJIT.") AddSconsOption('luajit', False, False, "Enable LuaJIT")
AddSconsOption('lua52', False, False, "Compile using lua 5.2")
AddSconsOption('nofft', False, False, "Disable FFT.") AddSconsOption('nofft', False, False, "Disable FFT.")
AddSconsOption("output", False, True, "Executable output name.") AddSconsOption("output", False, True, "Executable output name.")
@ -254,29 +255,41 @@ def findLibs(env, conf):
#Look for Lua #Look for Lua
luaver = "lua5.1" luaver = "lua5.1"
if GetOption('luajit'): if GetOption('luajit'):
if not conf.CheckLib(['luajit-5.1', 'luajit']): if not conf.CheckLib(['luajit-5.1', 'luajit5.1', 'luajit']):
FatalError("luajit development library not found or not installed") FatalError("luajit development library not found or not installed")
env.Append(CPPDEFINES=["LUAJIT"])
luaver = "luajit" luaver = "luajit"
elif GetOption('lua52'):
if not conf.CheckLib(['lua5.2', 'lua-5.2', 'lua52']):
FatalError("lua5.2 development library not found or not installed")
env.Append(CPPDEFINES=["LUA_COMPAT_ALL"])
luaver = "lua5.2"
else: else:
if not conf.CheckLib(['lua5.1', 'lua-5.1', 'lua51', 'lua']): if not conf.CheckLib(['lua5.1', 'lua-5.1', 'lua51', 'lua']):
if conf.CheckLib(['lua5.2', 'lua-5.2', 'lua52']): if platform != "Darwin" or not conf.CheckFramework("Lua"):
env.Append(CPPDEFINES=["LUA_COMPAT_ALL"])
luaver = "lua5.2"
elif platform != "Darwin" or not conf.CheckFramework("Lua"):
FatalError("lua5.1 development library not found or not installed") FatalError("lua5.1 development library not found or not installed")
if platform == "Linux": if platform == "Linux":
try: try:
env.ParseConfig("pkg-config --cflags {0}".format(luaver)) env.ParseConfig("pkg-config --cflags {0}".format(luaver))
env.ParseConfig("pkg-config --libs {0}".format(luaver)) env.ParseConfig("pkg-config --libs {0}".format(luaver))
env.Append(CPPDEFINES=["LUA_R_INCL"])
except: except:
pass pass
else:
#Look for lua.h #Look for lua.h
if not conf.CheckCHeader('lua.h'): foundheader = False
if conf.CheckCHeader('lua5.1/lua.h'): if GetOption('luajit'):
env.Append(CPPDEFINES=["LUA_INC"]) foundheader = conf.CheckCHeader('luajit-2.0/lua.h')
elif GetOption('lua52'):
foundheader = conf.CheckCHeader('lua5.2/lua.h')
else: else:
FatalError("lua.h not found") foundheader = conf.CheckCHeader('lua5.1/lua.h')
if not foundheader:
if conf.CheckCHeader('lua.h'):
env.Append(CPPDEFINES=["LUA_R_INCL"])
else:
FatalError("lua.h not found")
#Look for fftw #Look for fftw
if not GetOption('nofft') and not conf.CheckLib(['fftw3f', 'fftw3f-3', 'libfftw3f-3']): if not GetOption('nofft') and not conf.CheckLib(['fftw3f', 'fftw3f-3', 'libfftw3f-3']):

View File

@ -6,14 +6,22 @@ extern "C"
{ {
#endif #endif
#ifdef LUA_INC #if defined(LUA_R_INCL)
#include "lua5.1/lua.h"
#include "lua5.1/lauxlib.h"
#include "lua5.1/lualib.h"
#else
#include "lua.h" #include "lua.h"
#include "lauxlib.h" #include "lauxlib.h"
#include "lualib.h" #include "lualib.h"
#elif LUA_VERSION_NUM >= 502
#include "lua5.2/lua.h"
#include "lua5.2/lauxlib.h"
#include "lua5.2/lualib.h"
#elif defined(LUAJIT)
#include "luajit-2.0/lua.h"
#include "luajit-2.0/lauxlib.h"
#include "luajit-2.0/lualib.h"
#else
#include "lua5.1/lua.h"
#include "lua5.1/lauxlib.h"
#include "lua5.1/lualib.h"
#endif #endif
#if LUA_VERSION_NUM >= 502 #if LUA_VERSION_NUM >= 502