Use macros to reduce code duplication

I added the make_library and make_tests user defined functions which
expand to setup the variables and rules need to build libraries and
unit test programs.