Update Makefiles and fix dependencies