# File lib/mkmf-gnome2.rb, line 80
def add_depend_package(target_name, target_srcdir, top_srcdir, options={})
  begin
    require 'rubygems'
    gem_spec = Gem.source_index.find_name(target_name).last
    if gem_spec
      target_source_dir = File.join(gem_spec.full_gem_path, "ext/#{target_name}")
      target_build_dir = target_source_dir
      add_depend_package_path(target_name,
                              target_source_dir,
                              target_build_dir)
    end
  rescue LoadError
  end

  [top_srcdir,
   File.join(top_srcdir, target_name),
   $configure_args['--topdir'],
   File.join($configure_args['--topdir'], target_name)].each do |topdir|
    topdir = File.expand_path(topdir)
    target_source_dir_full_path = File.join(topdir, target_srcdir)

    top_build_dir = options[:top_build_dir] || topdir
    target_build_dir = options[:target_build_dir] || target_srcdir
    target_build_dir_full_path = File.join(top_build_dir, target_build_dir)
    unless File.exist?(target_build_dir_full_path)
      target_build_dir_full_path = File.join(top_build_dir, target_srcdir)
    end
    unless File.exist?(target_build_dir_full_path)
      target_build_dir_full_path = File.join(topdir, target_build_dir)
    end
    unless File.exist?(target_build_dir_full_path)
      target_build_dir_full_path = File.join(topdir, target_srcdir)
    end
    add_depend_package_path(target_name,
                            target_source_dir_full_path,
                            target_build_dir_full_path)
  end
end