Moved more rules out of test and lib makefiles into common makefiles.