Makefile: refactor lookup of pkg build rules and deps

Introduces a LOOKUP_PKG_RULE function that matches generic rules
from targets specified along the lines of:

triplet.lib-type.debug.treading.exceptions.my.experimental.version

Current build rules will be matched according to the current logic
(pkg-target --> pkg) and future variants can use "targets" as both
functionality determinants and a directory separator for multiple
side-by-side variants.
packages gcc sdl_rwhttp: use new-style target-specific deps
Merge pull request #320 from tonytheodore/lookup-pkg-rule

Makefile: refactor lookup of pkg build rules and deps