Fixed makefiles. Added some scripts to calc dependencies.