Skip to content

Commit

Permalink
--luajit and --lua52 compile options
Browse files Browse the repository at this point in the history
no longer looks for lua 5.2 unless you tell it to
  • Loading branch information
jacob1 committed Feb 13, 2015
1 parent 03e0794 commit 316d0f1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
37 changes: 25 additions & 12 deletions SConscript
Expand Up @@ -70,7 +70,8 @@ AddSconsOption('renderer', False, False, "Build the save renderer.")
AddSconsOption('wall', False, False, "Error on all warnings.")
AddSconsOption('no-warnings', False, False, "Disable all compiler warnings.")
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("output", False, True, "Executable output name.")

Expand Down Expand Up @@ -254,29 +255,41 @@ def findLibs(env, conf):
#Look for Lua
luaver = "lua5.1"
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")
env.Append(CPPDEFINES=["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:
if not conf.CheckLib(['lua5.1', 'lua-5.1', 'lua51', 'lua']):
if conf.CheckLib(['lua5.2', 'lua-5.2', 'lua52']):
env.Append(CPPDEFINES=["LUA_COMPAT_ALL"])
luaver = "lua5.2"
elif platform != "Darwin" or not conf.CheckFramework("Lua"):
if platform != "Darwin" or not conf.CheckFramework("Lua"):
FatalError("lua5.1 development library not found or not installed")

if platform == "Linux":
try:
env.ParseConfig("pkg-config --cflags {0}".format(luaver))
env.ParseConfig("pkg-config --libs {0}".format(luaver))
env.Append(CPPDEFINES=["LUA_R_INCL"])
except:
pass

#Look for lua.h
if not conf.CheckCHeader('lua.h'):
if conf.CheckCHeader('lua5.1/lua.h'):
env.Append(CPPDEFINES=["LUA_INC"])
else:
#Look for lua.h
foundheader = False
if GetOption('luajit'):
foundheader = conf.CheckCHeader('luajit-2.0/lua.h')
elif GetOption('lua52'):
foundheader = conf.CheckCHeader('lua5.2/lua.h')
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
if not GetOption('nofft') and not conf.CheckLib(['fftw3f', 'fftw3f-3', 'libfftw3f-3']):
Expand Down
18 changes: 13 additions & 5 deletions src/lua/LuaCompat.h
Expand Up @@ -6,14 +6,22 @@ extern "C"
{
#endif

#ifdef LUA_INC
#include "lua5.1/lua.h"
#include "lua5.1/lauxlib.h"
#include "lua5.1/lualib.h"
#else
#if defined(LUA_R_INCL)
#include "lua.h"
#include "lauxlib.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

#if LUA_VERSION_NUM >= 502
Expand Down

0 comments on commit 316d0f1

Please sign in to comment.