ARCHIVED: Checkout LadyLua for your standalone Lua programs.

May 22, 2021 ยท View on GitHub

Compile Lua 5.1 and LuaJIT source code into standalone executables. This makes it easy to use them for general purpose scripting.

Requires: GNU Make, a compiler and binutils (or equivalent). Installing development tools e.g. the package build-essential should have everything you need. Does not require autotools.
Note: Linux 3.17+ (5 Oct 2014) and glibc 2.25+ only for getrandom().

Getting started

  1. Edit the following space delimited variables in the top-level Makefile
    MAIN: The "main" script in the bin/ directory
    SRC: Modules that are specific to your application. Copy these to src/lua.
    SRC_DIR: Directories containing modules that are specific to your application. Copy these to src/lua.
    VENDOR: 3rd party modules
    VENDOR_DIR: directories containing 3rd party modules

  2. Copy the main source file into the bin/ directory.

  3. Copy modules into src/lua/ or vendor/lua/.

The SRC, VENDOR split is just for organization. Underneath they are using the same Make routines.

  1. Run make
  2. The executable will be located under the bin/ directory

Adding plain Lua modules. (NOTE: VENDOR and SRC are interchangeable.)

Adding plain modules is trivial. $(NAME) is the name of the module passed to VENDOR.

  1. Copy the module to vendor/lua/$(NAME).lua
    example: cp ~/Downloads/dkjson.lua vendor/lua
  2. Add $(NAME) to VENDOR
    example: VENDOR= re dkjson

For modules that are split into multile files, such as Penlight:

  1. Copy the directory of the Lua to vendor/lua/$(NAME)
    example: cp -R ~/Download/Penlight-1.3.1/lua/pl vendor/lua
  2. Add $(NAME) to VENDOR_DIR
    example: VENDOR_DIR= pl

For modules with multiple levels of directories you will have to pass each directory. Example:
VENDOR_DIR= ldoc ldoc/builtin ldoc/html

Lua does not have facilities to traverse directories and I'd like to avoid shell out functions.

Included projects

ProjectVersionLicense
LuaJITv2.1-20201012-2MIT
luastatic0.0.12CC0

Available modules (Feel free to open a Github issue if you want help with adding a new Lua module.)

ModuleVersionLicense
LPegLJ[1]1.0.0MIT
luafilesystem0.3MIT
u-test113259fMIT
argparse20c1445MIT
moonscript29d8cccMIT
lunajson1dcf3faMIT
base64769e16dAPL2
sqlite3[3]d742002MIT
luassert[2]36fc3afMIT
list7f8ee88MIT
yamld280b04MIT

[1] Renamed to lpeg. require"lpeg" to require it.
[2] Incomplete import. Some files, utility type code only.
[3] Patched.