lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I've got the same issue... but I need the lua interpreter to be
"relocatable" (aka copy into an arbitrary directory and it still needs
to work).  To do this, I made the following changes:

 [1] Set the LUA_ROOT global variable to dirname(dirname(argv[0])) in
pmain() of lua.c

 [2] Modify setpath() in loadlib.c so it replaces the special "..."
token with the LUA_ROOT global variable and if that fails, fall-back
to the LUA_ROOT compile time define.

 [3] Modify LUA_LDIR and LUA_CDIR so they use the special "..." token
instead of the hard-coded LUA_ROOT compile time define.

The net result is a lua interpreter that can be relocated... and if
someone uses just the lua library, they can set the LUA_ROOT global
variable if they want to relocate it to a new directory.

I can send a patch if someone is interested (technically, I made the
above changes for the "luajit" branch, but it should be possible to do
the same thing in lua 5.2).


On Thu, Aug 4, 2011 at 8:14 AM, Jim Whitehead II <> wrote:
> I previously reported this for Lua-5.1, but I'd like to reiterate it
> for Lua-5.2 if possible before that version is released. I quite
> frequently script the installation of Lua in a non-global environment,
> sandboxing it to a project directory. This works fine, I can specify
> INSTALL_TOP on the command line, but the path /usr/local is still
> hardcoded in luaconf.h and there's no way to overwrite it without
> editing the file directly.
> --- luaconf_orig.h      2011-08-04 16:02:16.000000000 +0100
> +++ luaconf.h   2011-08-04 16:03:15.000000000 +0100
> @@ -99,7 +99,9 @@
>  #else                  /* }{ */
> +#ifndef LUA_ROOT
>  #define LUA_ROOT       "/usr/local/"
> +#endif
>  #define LUA_LDIR       LUA_ROOT "share/lua/" LUA_VDIR
>  #define LUA_CDIR       LUA_ROOT "lib/lua/" LUA_VDIR
>  #define LUA_PATH_DEFAULT  \
> This would allow me to define LUA_ROOT on the command line and invoke
> make in the src directory. I'm not tied to this particular solution,
> but I would love to be able to specify a custom value for LUA_ROOT
> without needing to alter luaconf.h.
> - Jim

Brian Maher >> Glory to God <<