Extract repeated Makefile

A great deal of duplication is removed.