1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#!/usr/bin/ruby
require 'mkmf'
def rule(target, clean = nil)
wr = "#{target}:
\t@for subdir in $(SUBDIRS); do \\
\t\t(cd $${subdir} && $(MAKE) #{target}); \\
\tdone;
"
if clean != nil
wr << "\t@-rm tmp/* tests/tmp/* 2> /dev/null\n"
wr << "\t@rm Makefile\n" if clean
end
wr
end
subdirs = if $configure_args.has_key?("--make")
[]
else
Dir["*"].select do |subdir|
/\Abdbxml/ !~ subdir && File.file?(subdir + "/extconf.rb")
end
end
begin
make = open("Makefile", "w")
make.print <<-EOF
SUBDIRS = #{subdirs.join(' ')}
#{rule('all')}
#{rule('static')}
#{rule('clean', false)}
#{rule('distclean', true)}
#{rule('realclean', true)}
#{rule('install')}
#{rule('site-install')}
#{rule('unknown')}
%.html: %.rd
\trd2 $< > ${<:%.rd=%.html}
EOF
make.print "HTML = bdb.html"
docs = Dir['docs/*.rd']
docs.each {|x| make.print " \\\n\t#{x.sub(/\.rd$/, '.html')}" }
make.print "\n\nRDOC = bdb.rd"
docs.each {|x| make.print " \\\n\t#{x}" }
make.puts
make.print <<-EOF
rdoc: docs/doc/index.html
docs/doc/index.html: $(RDOC)
\t@-(cd docs; rdoc .)
ri:
\t@-(rdoc -r docs/*rb)
ri-site:
\t@-(rdoc -R docs/*rb)
rd2: html
html: $(HTML)
test: $(DLLIB)
EOF
Dir.foreach('tests') do |x|
next if /^\./ =~ x || /(_\.rb|~)$/ =~ x
next if FileTest.directory?(x)
make.print "\t#{CONFIG['RUBY_INSTALL_NAME']} tests/#{x}\n"
end
ensure
make.close
end
subdirs.each do |subdir|
STDERR.puts("#{$0}: Entering directory `#{subdir}'")
Dir.chdir(subdir)
system("#{CONFIG['RUBY_INSTALL_NAME']} extconf.rb " + ARGV.join(" "))
Dir.chdir("..")
STDERR.puts("#{$0}: Leaving directory `#{subdir}'")
end
$makefile_created = true
|