Cleanup build to localize flags for external packages.

Cleaning up configure so that compile/link flags for external packages are only used by the minimal set of modules that need them.  Ideally, this will minimize build and namespace conflicts, reduce executable sizes, and make command lines easier to read.

Don't merge yet, still tweaking.

I believe the reason I separated these is because archives need to come before dynamic libraries otherwise they may (and sometimes did) have undefined references.