Fix handling of sources/intermediates

A "source" is something that exists in the build tree before we start
and has a name in srcnames[].  An "intermediate" is something that we
generate as part of the build process and then use as an input to a
subsequent step.

All exports are intermediates.

We currently only use intermediates as link inputs.  (This is more
consistently broken than the previous handling; it's still broken in a way
we don't exercise.)
Read configurable link rules

We still make assumptions about what they are, that will be removed over
the next few commits.
Fix link rule output dependencies

Now we use both sources and intermediates, and don't make assumptions
about what types we want.
Remove obsolete function
Get name to use for an input file

How the name is built depends on whether it's a source or intermediate.
This is progress toward making most of the code not care about that
distinction.
Generalize handling of inputs
intermediates[] is now redundant
Warn if we don't know what to do with a source

If it isn't a direct input to modules of the type we're linking, and we
don't know how to compile it to something that is, we complain.
Add 'next' to actions as appropriate
Change index order of sources array
Array slicing and dicing functions
Write compile rules in a batch

Instead of per-module.
This fixes two glitches in the compile rules we output:
1. Exported compile outputs that weren't part of a module in the
   exporting build description file didn't get compiled
2. If two modules referenced the same source (instead of using an
   exported compile output) the build rule got written twice
Resolve imports late

The actual visibility was based on the order we read inputs, which is
breadth-first and doesn't match any visibility rules sensible people will
expect.
So resolve imports after we've read everything, which makes all exports
globally visible.
Update TODO