Re: [PATCH] Allow external definition of Lua library paths in luaconf.h
Marc Balmer <[email protected]>
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
> Am 09.02.2026 um 01:37 schrieb Matěj Cepl <[email protected]>: > > ping? Is there any hope this could be reviewed? are you aware that you can set both LUA_PATH and LUA_CPATH at runtime? > > Dne středa 31. prosince 2025 v 14:34:46 UTC+1 uživatel Matěj Cepl napsal: >> Currently, `LUA_LDIR` and `LUA_CDIR` are hardcoded in `luaconf.h` to >> `share/lua/` and `lib/lua/` relative to `LUA_ROOT`. This structure >> limits the ability to install Lua C extensions into system-specific >> directories, such as `/usr/lib64` on compatible Linux distributions, >> without modifying the source code directly. >> >> This commit modifies `luaconf.h` to check if `LUA_LDIR` or `LUA_CDIR` >> are already defined (e.g., via compiler flags like >> `-DLUA_CDIR="/usr/lib64/lua/5.5/"`). If defined, these values are >> stringified and used; otherwise, the default paths are preserved. This >> change improves build system flexibility and multi-arch support. >> >> Signed-off-by: Matěj Cepl <[email protected] <>> >> --- >> luaconf.h | 25 ++++++++++++++++++++----- >> 1 file changed, 20 insertions(+), 5 deletions(-) >> >> diff --git a/luaconf.h b/luaconf.h >> index 96a77802..4fccaa64 100644 >> --- a/luaconf.h >> +++ b/luaconf.h >> @@ -224,8 +224,8 @@ >> >> #if !defined(LUA_PATH_DEFAULT) >> #define LUA_PATH_DEFAULT \ >> - LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ >> - LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ >> + LUA_LDIR_PATH"?.lua;" LUA_LDIR_PATH"?/init.lua;" \ >> + LUA_CDIR_PATH"?.lua;" LUA_CDIR_PATH"?/init.lua;" \ >> LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ >> ".\\?.lua;" ".\\?\\init.lua" >> #endif >> @@ -239,9 +239,24 @@ >> >> #else /* }{ */ >> >> +#ifndef LUA_ROOT >> #define LUA_ROOT "/usr/local/" >> -#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" >> -#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" >> +#endif >> + >> +#define LUA_STR_HELPER(x) #x >> +#define LUA_STR(x) LUA_STR_HELPER(x) >> + >> +#ifdef LUA_LDIR >> +#define LUA_LDIR_PATH LUA_STR(LUA_LDIR) >> +#else >> +#define LUA_LDIR_PATH LUA_ROOT "share/lua/" LUA_VDIR "/" >> +#endif >> + >> +#ifdef LUA_CDIR >> +#define LUA_CDIR_PATH LUA_STR(LUA_CDIR) >> +#else >> +#define LUA_CDIR_PATH LUA_ROOT "lib/lua/" LUA_VDIR "/" >> +#endif >> >> #if !defined(LUA_PATH_DEFAULT) >> #define LUA_PATH_DEFAULT \ >> @@ -252,7 +267,7 @@ >> >> #if !defined(LUA_CPATH_DEFAULT) >> #define LUA_CPATH_DEFAULT \ >> - LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" >> + LUA_CDIR_PATH"?.so;" LUA_CDIR_PATH"loadall.so;" "./?.so" >> #endif >> >> #endif /* } */ >> -- >> 2.52.0 >> > > > -- > You received this message because you are subscribed to the Google Groups "lua-l" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. > To view this discussion visit https://groups.google.com/d/msgid/lua-l/350ecbda-5667-496c-9418-bed0230c2bf3n%40googlegroups.com <https://groups.google.com/d/msgid/lua-l/350ecbda-5667-496c-9418-bed0230c2bf3n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/8E860B90-432D-40AE-A886-5B160E0012B7%40gmail.com.