lua-users home
lua-l archive

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

It was thus said that the Great Vadim A. Misbakh-Soloviov once stated:
> > 1) What about environment variables?  Would doing the following help?
> > 
> > 	LUA         ?= lua
> > 	LUA_VERSION  = $(shell $(LUA) -e "io.stdout:write(_VERSION:match '^Lua
> > (.*)','\n')") LIBDIR      ?= $(LUA_DIR)/lib/lua/$(LUA_VERSION)
> > 	LUADIR      ?= $(LUA_DIR)/share/lua/$(LUA_VERSION)
> > 
> > Then you could set $LUA (and $LIBDIR and $LUADIR) since that seems to be all
> > you change in the Makefile (and these are the ones LuaRocks define for use
> > in Makefiles).
> Yeah, it will help a bit (excluding missed `LUA_DIR` variable naming in 
> `LIBDIR`/`LUADIR` values), so I'll be able to just place variable definitions 
> to configure stage, instead of patching :)
> And, by the way, luadir/libdir definition could be "old", with lua calls 
> (because it will return right paths for current lua implementation, which can 
> be not in $prefix/lib/, but in $prefix/lib64 or $prefix/libx32 or even libo32/
> libn32 on some arches.

  Would the following work?

	prefix      ?= /usr/local
	libdir      ?= $(prefix)/lib
	datarootdir ?= $(prefix)/share
	dataroot    ?= $(datarootdir)

	LUA         ?= lua
	LUA_VERSION := $(shell $(LUA) -e "io.stdout:write(_VERSION:match '^Lua (.*)','\n')")
	LIBDIR      ?= $(libdir)/lua/$(LUA_VERSION)
	LUADIR      ?= $(dataroot)/lua/$(LUA_VERSION)

It's more inline with GNU standards (the prefix/libdir/datarootdir/dataroot)
and since all the calls are with '?=' the environment variables should be
picked up correctly.

  The reason for LUA_VERSION being defined as ':=' is to evaluate it once,
not each time it's referenced (which is really in the definition of LIBDIR
and LUADIR if it's not already defined).