On Fri, Jan 01, 2016 at 03:09:57PM +0000, Meer, Hans van der wrote:
> I would like to switch from 5.2 to 5.3.
> However, if incompatibilities arise then a switch back to 5.2 should be
> easy. Something like LUA_VERSION=5.3 instead of LUA_VERSION=5.2 in the
> .bashrc file.
My luapath project contains two portable shell scripts you might find
useful, luapath and runlua.
luapath - locates interpreter, include, module, and library paths for help
building and installing Lua modules. It's intended function is similar to
pkg-config, except it doesn't require pkg-config, any other dependency, or
even any cooperation. It will use (after verifying) pkg-config variables,
but does much more, and is especially useful when dealing with ad hoc Lua
installations (e.g. not distribution packages). NB: the various search
heuristics must be specifically requested--I usually always specify -krm5.
runlua - locates and executes interpreter by API or release version. It can
be called similar to the PUC Lua binary. (But see below.) It supports both
command-line arguments and environment variables for choosing the Lua
version. Command-line arguments override environment variables, but you can
reverse that by prepending "!" to the environment value.
The additional -t switch solves some pthread issues. FreeBSD, NetBSD, and
OpenBSD do not support loading libpthread at runtime (e.g. as a dependency
of a module). glibc nominally supports loading libpthread dynamically, but
there are several very old, very critical open bugs related to their
support. As an alternative to recompiling the Lua VM (which AFAIK
distributions don't yet do for Lua like they do for Perl, Python, and Ruby),
the -t switch will attempt to use special linker environment variables to
load libpthread at invocation time.
Because runlua is a shell script which uses shebang, you cannot portably
call runlua from the shebang. In my tests only the Linux and OS X kernels
support shebang chaining. Instead, I usually use this construct:
# You can do useful stuff here, like using getopts(1) or setting up
# the environment. Nice if you don't want to create a dependency
# on luaposix or similar modules.
If I want to force the script to use a different version, I can just set
> My question: if I do "make install" in the 5.3 codebase is this still doable? Or will there be confusion between the two versions, making a simple switch in this manner undoable?
The default Makefile flags will install the interpreter to
/usr/local/bin/lua, overwriting whatever was there. I usually install Lua
into separate /usr/local/luaNN or /opt/luaNN directories. Package managers
will usually install the interpreters into the same bin/ directory, but
suffixed with NN, -NN, or -N.N; they may make lua a symlink to one of them.
> By the way, in the .bashrc-file I have configured lua as follows:
> export LUA_VERSION
> export LUA_DIR
> export LUA_INCL
> export LUA_SHAREDIR
> export LUA_LIBDIR
> export LUA_PATH
> export LUA_CPATH
What I usually do is set all of these unconditionally: