Better placement of badge generation code
Enable badge image generation when invoked via the Makefile

This should cause badges to be routinely produced on the server.

See #2099