lua-users home
lua-l archive

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

Over the years, there have been several replies to suggested patches
on this list, saying "no need to patch Lua".

The trick is not described in the "Customization" section of
'doc/readme.html' so this post has the dual purpose of documenting it
here (probably not for the first tine) and pleading that a better (not
Linux-specfic, and also saying how to do it for liblua.a or liblua.dll
as the case may be) description than mine might in future be described

A customized version of Lua that would affect only non-header files,
i.e. files with names ending in ".c", never requires patching Lua
itself. The job can be done from the command line, illustrated here
for two such files under Linux.

The key points are:

1. All external names used by Lua are declared in header files.
2. If such a name has been resolved by an object file or library
linked earlier, the linker will be satisfied and will not replace it.
3. Any .o files needed by the linker will be built automatically from
.c files by the Makefile rules.

So all that is necessary is:

1. In the Lua source directory, save your modified files with another
prefix, say "my", instead ol "l" starting their names, e.g.
'myctype.c' and 'mylex.c'.
2. When you want a new 'lua' including your most recent modifcations:
    rm my*.o     # necessary because the Makefile does not know about them
    make linux -e "LUA_O=  lua.o myctype.o mylex.o"