Move stuff to top-level

This makes it easier to use with "git subtree".
Remove duplicate elements from *_SOURCES

This is useful when you do:

  foo_SOURCES := $(wildcard *.cc) foo.cc

where foo.cc is a generated file.  In this case, if foo.cc already
exists, you get foo.cc twice in foo_SOURCES, leading to a link error.
Declare template_files as a simply expanded variable