core: let the makefile only check toplevel dirs in deps. Prevents unneeded recursion into sub-directories.

(cherry picked from commit dc1201bbdf7ff0d68e29d0d37b311f0fa1c09cdd)