rearrange so that most of the server code can be linked without main.c

Move global variables and one function out of main.c so that the rest of
the server can be linked with a test harness.
Test the low-level code in uloc.c

Also, tweak the debian build infrastructure so that we can pass
in arbitrary CFLAGS.

New program test_server that links with the non-main.c parts of
the server.  Currently only (as above) tests the low-level bits
of uloc.c.