erlc: fix a bug in handling of files to compile first

If a file that is depended upon itself depends on other files, make sure
those are compiled first.

Reported-by: David Robakowski
erlc: rename variables for correctness