Someone who is building from source might want to get acquainted with the minutiae of their package manager.
Code:
[eschwartz@arch ~]$ pacman -Qo /usr/include/GL/gl.h
/usr/include/GL/gl.h is owned by mesa 11.0.6-1
I am sure debian must have some similar command.
And a script that checks for needed libraries could wrap the search feature of various package managers.
...
Of course, as you say, knowing what to check for is a feat all of its own.