Fix linux build

A series of commits to fix, clean and improve Linux Makefiles.