Don't add generated sources to _SOURCES
Conditionalize sqlite libs
Move some stuff up

No functional changes
Remove unneeded flags from tools