Revert the 'clean-up' commits so that custom build-time flags can be set

These commits removed the 'NEEDED*' vars which were added so that CXX*
and LDFLAGS could be specified at build time. By doing away with these
and using solely CXXFLAGS and LDFLAGS, special flags cannot be added.
Indeed, specifying your own CXXFLAGS would cause the build to fail. We
want the build flags to be APPENDED, not overwritten.
add explanatory comments to Makefiles
Fix building in kFreeBSD

broken in 8c218bd5
Don't build the lib when making static binaries

Without this, building on 64-bit systems will fail.
Add api target
slightly stricter use of mkdir/rm -rf