modify makefile to allow more customisations

allow compiler/flags to be defined outside the makefile (for submake)

compile shared library from .c files not objects (I need the shared lib
to be compiled by a different CC from the static lib and this seems like
a nice way apart from the a small increase in compile time).
dont call pre/post write callbacks if callback is null
Merge pull request #30 from coherentsolutions/master

dont call pre/post write callbacks if callback is null