richardhundt/shine — pull request #66 by leonidborisenko (2014-09-25 00:44:37+00:00)
Title: Allow custom PREFIX and MILTILIB in building TvmJIT

Build directory had been leaked in default `package.path` and `package.cpath`. You can see it in following example (I was building in `/tmp/shine`).

Setting custom `PREFIX` and `MULTILIB` in building TvmJIT is useful for accessing distro Lua libraries.

---

`~: ./build/shine -e 'print "path: %{package.path}\n\ncpath: %{package.cpath}"'`
* before patch:
```
path: ./?/init.shn;./lib/?/init.shn;/usr/local/share/shine/?/init.shn;./?.shn;./lib/?.shn;/usr/local/share/shine/?.shn;./lib/?.raw;./lib/?.lua;./?.lua;/tmp/shine/build/share/tvmjit-0.1.3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/tmp/shine/build/share/lua/5.1/?.lua;/tmp/shine/build/share/lua/5.1/?/init.lua;

cpath: /usr/local/lib/shine/?.so;./lib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/tmp/shine/build/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;
```
* after patch (without customizing `PREFIX` and `MULTILIB`):
```
path: ./?/init.shn;./lib/?/init.shn;/usr/local/share/shine/?/init.shn;./?.shn;./lib/?.shn;/usr/local/share/shine/?.shn;./lib/?.raw;./lib/?.lua;./?.lua;/usr/local/share/tvmjit-0.1.3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;

cpath: /usr/local/lib/shine/?.so;./lib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;
```
* after patch (with using `make TVMJIT_PREFIX=/usr TVMJIT_MULTILIB="lib/$(gcc -print-multiarch)"`):
```
path: ./?/init.shn;./lib/?/init.shn;/usr/local/share/shine/?/init.shn;./?.shn;./lib/?.shn;/usr/local/share/shine/?.shn;./lib/?.raw;./lib/?.lua;./?.lua;/usr/share/tvmjit-0.1.3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;

cpath: /usr/local/lib/shine/?.so;./lib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/i386-linux-gnu/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;
```

LuaJIT on Debian:
`~: luajit -v -e 'print("path: "..package.path.."\n\ncpath: "..package.cpath)'`
```
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
path: ./?.lua;/usr/share/luajit-2.0.3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua

cpath: ./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/i386-linux-gnu/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
```