[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] luapath - Lua header and interpreter path locator utility
- From: William Ahern <william@...>
- Date: Fri, 2 Aug 2013 22:00:31 -0700
Because Lua installations are not uniform, even across Linux distributions
let alone other open source and proprietary environments; and because the
problems are only compounded in mixed 5.1, 5.2, and JIT environments; and
because uniform build frameworks like LuaRocks or configuration databases
like pkg-config aren't universally available (especially in proprietary
environments); I've written a script to help discover and untangle the mess
of header and interpreter paths for Unix systems.
It's basically just a small shell script you integrate into your Makefile or
configuration script. I currently use it in several projects to help me
concurrently build 5.1 and 5.2 modules, where I cannot simply require
separate invocations of a larger build using different flags, and where I
cannot trust header locations not to change. I use it to generate any
necessary additional CPPFLAGS, assert that a C or C++ source file is
building against the proper headers, and to locate the correct luac utility
for syntax checking of a Lua script module before installation.
It has no dependencies beyond POSIX-compatible sh, cc, find, and sed (and nm
and grep for the unfinished linker work). Tested on several different Linux
systems, OS X, Solaris, NetBSD, and FreeBSD.
Here's the usage message:
usage: luapath [-I:L:P:rm:xsv:j:JVh] cppflags|ldflags|version|lua|luac
-I PATH additional search directory for includes
-L PATH additional search directory for libraries
-P PATH additional search directory for binaries
-r recursively search directories
-m MAXDEPTH limit recursion to MAXDEPTH (only for GNU and BSD find)
-x do not cross device mounts when recursing
-s find shortest pathname, otherwise print first best match
-v VERSION require specific Lua version or range
(e.g. "5.1" or "5.1-5.2")
-j VERSION require specific LuaJIT version or range
(e.g. "2.0.1"; empty ranges like "-" force any LuaJIT version)
-J skip LuaJIT if encountered
-V print this script's version information
-h print this usage message
cppflags print derived additional CPPFLAGS necessary
ldflags print derived additional LDFLAGS necessary (TODO)
version print derived Lua API version
luac [GLOB] print path to luac utility using optional glob patterns
(e.g. "luac5.?"; default is "luac*")
lua [GLOB] print path to lua interpreter using optional glob patterns
(e.g. "lua luajit"; default is "lua*")
evalmacro run internal macro evaluator for debugging
testsym run internal library symbol reader for debugging
This utility is used to derive compiler flags and filesystem paths
necessary to utilize Lua, LuaJIT, and particular versions thereof.
On success it prints the requested information and exits with 0,
otherwise it fails with an exit status of 1.
Note that cppflags may not print anything if no additional flags are
required to compile against the requested API version.
When searching, the highest Lua version is preferred. Searching
stops once the highest version in the allowable range is found
unless the -s flag is specified.
LuaJIT is treated like any other Lua installation. If an explicit
LuaJIT version or range is specified, then only LuaJIT installations
will match. To exclude LuaJIT entirely use the -J switch.
This utility processes the environment variables CC, CPPFLAGS,
LDFLAGS, and PATH if present. If recursion is requested, then
directories specified in CPPFLAGS, LDFLAGS, and PATH are also
Report bugs to <william@25thandClement.com>