[PATCH] Allow external definition of Lua library paths in luaconf.h

122 views
Skip to first unread message

Matěj Cepl

unread,
Dec 31, 2025, 8:34:46 AM12/31/25
to lu...@googlegroups.com, Matěj Cepl
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 <mc...@cepl.eu>
---
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

Matěj Cepl

unread,
Feb 8, 2026, 7:37:59 PM (3 days ago) Feb 8
to lua-l
ping? Is there any hope this could be reviewed?

Dne středa 31. prosince 2025 v 14:34:46 UTC+1 uživatel Matěj Cepl napsal:

Marc Balmer

unread,
Feb 9, 2026, 2:51:17 AM (2 days ago) Feb 9
to lu...@googlegroups.com

Am 09.02.2026 um 01:37 schrieb Matěj Cepl <mc...@cepl.eu>:

ping? Is there any hope this could be reviewed?

are you aware that you can set both LUA_PATH and LUA_CPATH at runtime?

--
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 lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/350ecbda-5667-496c-9418-bed0230c2bf3n%40googlegroups.com.

Martin Eden

unread,
Feb 9, 2026, 9:38:07 AM (2 days ago) Feb 9
to lu...@googlegroups.com
On 2026-02-09 02:37, Matěj Cepl wrote:
> ping? Is there any hope this could be reviewed?
Hello Matěj

AFAIK Lua team does not accept patches. And never did.

It's almost one-man project lasting for over three decades.

So consider repo as read-only. You are free to make fork tho.

This maillist is just a bunch of Lua connoisseurs discussing
language and it's implementations details. And authors do read it
and sometimes respond.

-- Martin

Reply all
Reply to author
Forward
0 new messages