Fix dependency tracking

gcc -M -o ... writes dependencies only for the last target.