Start bringing in the Makefile.am from gitsh

This commit is a mess, sorry.

It introduces the `Makefile.am` from gitsh, and abstracts it a bit.
Everything from it works.

The Debian building code, which is not in gitsh, does not work however.
This is the middle of a pile of hacks to see how we can make this work.