fix Lua 5.1 library detection failed on Gentoo and derivatives

closes #6529
Merge pull request #6782 from Mailaender/configure-gentoo

Fixed Lua 5.1 library detection failed on Gentoo and derivatives