merge static/dynamic library build changes onto 4_5_x

application of the changes from #378 to the 4_5_x branch