Fixed broken make build, due to the -lm for the maths library being at the
start of the linking command line. It needs to be at the end, after all of
the object files.

Also re wrote the makefile so that dependencies between header files and
C files are configured automatically by running the depend target, and
there is also a target to build a cscope source code index.