# File mk, line 572
def compile(basename,target)
  done = false
  loop do
    # If there is a .fls file, and the target is there, then compile only if
    # there are tex_dep's or bib_dep's that are newer than target.
    # If there are bib_dep's newer than target, remove .bbl, forcing texi2dvi to run bibtex
    # Returns true if a compilation was actually performed.
    go = false
    if File.exist?(basename+'.fls') && File.exist?(target)
      targetmtime = File.mtime(target)
      bib_dep(basename).each do |f|
        if ! File.exist?(f) || File.mtime(f) > targetmtime
          rm(basename+'.bbl')
          puts("newer than target: #{f}") if @verbose
          go = true
          break
        end
      end
      unless go
        tex_dep(basename).each do |f|
          if ! File.exist?(f) || File.mtime(f) > targetmtime
            puts("newer than target: #{f}") if @verbose
            go = true
            break
          end
        end
      end
    else
      go = true
    end

    break unless go
    sys(@texcommand,true).success || show_error_and_edit(basename,target)
    done = true
  end
  return done
end