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.
erlc: rename variables for correctness