Fixed some of the mess in the Makefile

And fixed builds with multiple jobs and linking the smarttpl program.