Index: /trunk/nv/lib/lua.hh
===================================================================
--- /trunk/nv/lib/lua.hh	(revision 164)
+++ /trunk/nv/lib/lua.hh	(revision 165)
@@ -39,9 +39,11 @@
 
 #define NV_LUA_51     0
-#define NV_LUA_51_JIT 1
-#define NV_LUA_52     2
-
-#ifndef NV_LUA_VERSION
+#define NV_LUA_52     1
+
+#if !defined(NV_LUA_VERSION)
 #	define NV_LUA_VERSION NV_LUA_52
+#endif
+#if defined(NV_LUA_JIT)
+#	define NV_LUA_VERSION NV_LUA_51
 #endif
 
@@ -62,5 +64,9 @@
 #		define NV_LUA_PATH "lua5.1.so"
 #	endif
-#elif NV_LUA_VERSION == NV_LUA_51_JIT
+#else
+#	error "Unrecognized NV_LUA_VERSION!"
+#endif
+
+#if defined(NV_LUA_JIT)
 #	if NV_PLATFORM == NV_WINDOWS
 #		define NV_LUA_PATH "luajit.dll"
@@ -70,6 +76,4 @@
 #		define NV_LUA_PATH "luajit.so"
 #	endif
-#else
-#	error "Unrecognized NV_LUA_VERSION!"
 #endif
 
@@ -122,13 +126,13 @@
 #	define LUA_REGISTRYINDEX	LUAI_FIRSTPSEUDOIDX
 #	define lua_upvalueindex(i)	(LUA_REGISTRYINDEX - (i))
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
 #	define LUA_REGISTRYINDEX      (-10000)
 #	define LUA_ENVIRONINDEX       (-10001)
 #	define LUA_GLOBALSINDEX       (-10002)
 #	define lua_upvalueindex(i)    (LUA_GLOBALSINDEX-(i))
+#else
 #endif
 
 #define LUAL_BUFFERSIZE		BUFSIZ
-
 
 /* Types */
@@ -157,5 +161,5 @@
   char short_src[LUA_IDSIZE]; /* (S) */
   struct CallInfo *i_ci;  /* active function */
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
   int nups;
   int linedefined;	/* (S) */
@@ -163,4 +167,5 @@
   char short_src[LUA_IDSIZE]; /* (S) */
   int i_ci;  /* active function */
+#else
 #endif
 };
@@ -180,5 +185,5 @@
 	char initb[LUAL_BUFFERSIZE];  /* initial buffer */
 } luaL_Buffer;
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
 typedef struct luaL_Buffer {
 	char *p;
@@ -187,4 +192,5 @@
 	char initb[LUAL_BUFFERSIZE];
 } luaL_Buffer;
+#else
 #endif
 
@@ -210,7 +216,8 @@
 #	define LUA_ERRERR	6
 #	define LUA_ERRFILE  7
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
 #	define LUA_ERRERR	5
 #	define LUA_ERRFILE  6
+#else
 #endif
 
@@ -280,6 +287,7 @@
 #if NV_LUA_VERSION == NV_LUA_52
 #	define LUA_HOOKTAILCALL 4
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
 #	define LUA_HOOKTAILRET 4
+#else
 #endif
 
@@ -291,5 +299,4 @@
 
 /* lualib.h defines */
-#define LUA_COLIBNAME	"coroutine"
 #define LUA_TABLIBNAME	"table"
 #define LUA_IOLIBNAME	"io"
@@ -300,4 +307,5 @@
 #define LUA_LOADLIBNAME	"package"
 #if NV_LUA_VERSION == NV_LUA_52
+#	define LUA_COLIBNAME	"coroutine"
 #	define LUA_BITLIBNAME	"bit32"
 #endif
@@ -312,6 +320,9 @@
 #	define NV_LUA_FUN_51( rtype, fname, fparams )
 #	define NV_LUA_FUN_52 NV_LUA_FUN
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
 #	define NV_LUA_FUN_51 NV_LUA_FUN
+#	define NV_LUA_FUN_52( rtype, fname, fparams ) 
+#else
+#	define NV_LUA_FUN_51( rtype, fname, fparams )
 #	define NV_LUA_FUN_52( rtype, fname, fparams ) 
 #endif
@@ -347,7 +358,8 @@
 #if NV_LUA_VERSION == NV_LUA_52
 #	define lua_pushglobaltable(L)  lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
 #	define lua_setglobal(L,s)     lua_setfield(L, LUA_GLOBALSINDEX, (s))
 #	define lua_getglobal(L,s)     lua_getfield(L, LUA_GLOBALSINDEX, (s))
+#else
 #endif
 
@@ -378,7 +390,8 @@
 #	define luaL_addchar(B,c) ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), ((B)->b[(B)->n++] = (c)))
 #	define luaL_addsize(B,s)	((B)->n += (s))
-#else
+#elif NV_LUA_VERSION == NV_LUA_51
 #	define luaL_addchar(B,c) ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), (*(B)->p++ = (char)(c)))
 #	define luaL_addsize(B,n)  ((B)->p += (n))
+#else
 #endif
 
Index: /trunk/src/lib/lua.cc
===================================================================
--- /trunk/src/lib/lua.cc	(revision 164)
+++ /trunk/src/lib/lua.cc	(revision 165)
@@ -27,7 +27,10 @@
 #	define NV_LUA_FUN_51( rtype, fname, fparams )
 #	define NV_LUA_FUN_52 NV_LUA_FUN
+#elif NV_LUA_VERSION == NV_LUA_51
+#	define NV_LUA_FUN_51 NV_LUA_FUN
+#	define NV_LUA_FUN_52( rtype, fname, fparams ) 
 #else
-#	define NV_LUA_FUN_51 NV_LUA_FUN
-#	define NV_LUA_FUN_52( rtype, fname, fparams )
+#	define NV_LUA_FUN_51( rtype, fname, fparams )
+#	define NV_LUA_FUN_52( rtype, fname, fparams ) 
 #endif
 
@@ -48,14 +51,17 @@
 #		define NV_LUA_FUN_51( rtype, fname, fparams )
 #		define NV_LUA_FUN_52 NV_LUA_FUN
+#	elif NV_LUA_VERSION == NV_LUA_51
+#		define NV_LUA_FUN_51 NV_LUA_FUN
+#		define NV_LUA_FUN_52( rtype, fname, fparams ) 
 #	else
-#		define NV_LUA_FUN_51 NV_LUA_FUN
+#		define NV_LUA_FUN_51( rtype, fname, fparams )
 #		define NV_LUA_FUN_52( rtype, fname, fparams ) 
 #	endif
 
-#include <nv/lib/detail/lua_functions.inc>
+#	include <nv/lib/detail/lua_functions.inc>
 
-#undef NV_LUA_FUN
-#undef NV_LUA_FUN_51
-#undef NV_LUA_FUN_52
+#	undef NV_LUA_FUN
+#	undef NV_LUA_FUN_51
+#	undef NV_LUA_FUN_52
 	return true;
 }
