makefiles: fixes and speed-ups