Move more make code to rules.mk