configure.ac: refactor lua detection

All checks were nested which was really hard to read and modify
correctly. Instead use a state variable to track the detection status
and chain AS_IF condition for each test.
17 jobs for !24 with lua/refactor-arch/2 in 82 minutes and 34 seconds (queued for 2 seconds)
merge request