ninja: Store target-level flags in a variable

This greatly reduces the size of Ninja files projects with lots of flags
and lots of source files in libraries. ParaView goes from 110M to about
58M.
ninja: Factor out target-level order-only dependencies

This reduces ninja file output even more for projects with lots of
libraries with entangled transitive dependencies. ParaView goes from the
previous 58M to about 45M.