Improve Makefile dependency checks