build: allow to override the lua pkg-config

minor cleanup in the makefile while there
use memcmp for ends/startswith

This should be faster and fixes an unintialized value of 'i' error.