Fix non-POSIX problems, enhance build and fix -r bug

The first two commits in this series fix POSIX compatibility issues.  This is issue #21.
The next commit adds support for an optional config.mak and automatic rebuilding when prefix/etc options are changed just like Git has.
The last commit fixes commands that use -r remote such as 'tg -r origin info' so they actually work as the documentation says they do.

Lots more details in the log messages for each commit.