Makefile: speedup LOOKUP_PKG_RULE function

Use gmsl `memoize` function and associative arrays to cache results