compatibility with Lua 5.2 and 5.3-alpha

These modifications allow the test script to pass under Lua 5.2 and 5.3-alpha as well as 5.1.

Important changes:
* Makefile: compiles for Lua 5.2 by default, but this can be changed by specifing e.g. `make LUA_VERSION=5.1`
* Pass `NULL` for extra parameter to `lua_resume` on newer versions
* Move a lot of function prototype declarations up to before the first `luaL_reg` that references them
* Rename `luaL_reg` to `luaL_Reg` (???)
* Use `luaL_newlib` (and `lua_setglobal`) instead of `luaL_register` for Lua 5.2 and up
* Use `luaL_requiref` instead of `lua_cpcall` for 5.2 and up
* Don't register the module as a global in 5.2 and up, except in worker threads.
* My editor randomly changed a bunch of whitespace that also got included in the commit. :|