makefiles: improve build order