Add waf option to disable tj_solibrary and tj_log_sqlite.

These default to disabled if libdl or libsqlite3 (respectively) are not
detected.
Add waf option to disable building static or shared libraries.
Update waf version.
Use -O2 instead of -O3 when building in optimized mode.

GCC's -O3 throws out a bunch of bogus warnings (turned into errors with
-Werror) when in -O3 mode.  The more aggressive inlining causes
problems.