Automake

Fallbacks to lua5.1, if luajit is not available as the linking should be compatible.
Fix mysql detection and link properly against it.
Cleanup the configure.ac bit.