Fix a problem where multigcc.pl sometimes produces lines like "sh-elf-gcc: no input files", especially on systems with many cores and for builds with (relatively) few files.  This happened because the slice size was rounded up, which meant that in some cases there werere leftover slices.
Also remove the now unnecessary cores>files checking.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27196 a1c6a512-1295-4272-9138-f99709370657
diff --git a/tools/multigcc.pl b/tools/multigcc.pl
index 5222f61..9be9978 100755
--- a/tools/multigcc.pl
+++ b/tools/multigcc.pl
@@ -46,27 +46,25 @@
     }
 }
 
-# don't run empty children
-if (scalar @files <= $cores)
-{
-    $cores = 1;
-}
-
 # fork children
 my @pids;
 my $slice = int((scalar @files + $cores) / $cores);
-for my $i (0 .. $cores-1)
+
+# reset $cores to 0 so we can count the number of actually used cores
+$cores=0;
+
+for (my $i=0;$i<scalar @files;$i += $slice)
 {
     my $pid = fork;
     if ($pid)
     {
         # mother
-        $pids[$i] = $pid;
+        $pids[$cores++] = $pid;
     }
     else
     {
         # get my slice of the files
-        my @list = @files[$i * $slice .. $i * $slice + $slice - 1];
+        my @list = @files[$i .. $i + $slice - 1];
 
         # run command
         system("$command @list > $tempfile.$$");