# File mk, line 528
def bib_dep(basename)
  aux = "#{basename}.aux"
  File.exist?(aux) or return []
  bibs = []
  open(aux).readlines.each do |l|
    if m = l.match(/\\bibdata\{(.*)\}/)
      bibs = m[1].split(',').map{|x| x.sub(/\.bib/,'')+'.bib'}
      break if bibs
    end
  end
  return bibs if bibs.empty?
  bibs.uniq!
  bibs.map! do |b|
    bbib = kpsewhich(b) or quit("bib file #{b} not found",1)
    # following is needed because texi2dvi does not detect changes in
    # .bib files - if any included .bib file is newer than the .log
    # file, remove the .bbl file:
    File.exist?("#{b}.bbl") &&
    File.mtime(bbib) < File.mtime("#{basename}.log") and rm("#{basename}.bbl")
    bbib # add .bib extension to array elements
  end
  return bibs
end