lua-users home
lua-l archive

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


Hi,

Luiz Henrique de Figueiredo wrote:
> > INSTALL_LMOD= $(INSTALL_TOP)/share/lua/5.1
> > INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/5.1
> 
> I've heard you the first time, but I still don't know how to do this
> consistently with what is in luaconf.h.

It's not consistent, anyway. Changing /usr/local to /usr already
requires modifying _both_ src/luaconf.h and the Makefile. Adding
the preferred module installation paths to the Makefile doesn't
make things worse.


Ben Sunshine-Hill wrote:
> Well... after compilation, Lua knows them. How about a simple script
> to make the directories?

This doesn't work for cross-compilation. The built Lua binary may
not be executable on the host platform.

BTW: I've toyed with semi-automatic module installation and came
up with the script below. You can call it with
  lua cmodpath.lua my.module.name
and get back:
  /usr/local/lib/lua/5.1/my/module/name.so

But it's really guesswork, depending on how Lua was installed and
whether the 1st absolute path element is really the preferred
installation path for modules. I had to drop this due to problems
with cross-compilation and sandboxed installs, too.

pkg-config is widespread on Linux, but not elsewhere. Back to
editing Makefiles by hand I guess.

Bye,
     Mike


local function find_abs_sep(p)
  local s = string.sub(p, 1, 1)
  if s == '/' or s == '\\' then return s end
  return string.match(p, "^[a-zA-Z]:([/\\])")
end

local modname = arg and arg[1] or "?"

if package and package.cpath then
  for p in string.gfind(package.cpath, "[^;]+") do
    local sep = find_abs_sep(p)
    if sep then
      io.write(string.gsub(p, "%?", (string.gsub(modname, "%.", sep))), "\n")
      return
    end
  end
  io.write("No suitable absolute path found in package.cpath.\n")
else
  io.write("Lua 5.1 required but got ", _VERSION, "\n")
end
os.exit(1) -- Grrr. 'return x' doesn't set the exit status.