forked from knu/ruby-mmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extconf.rb
executable file
·77 lines (59 loc) · 1.58 KB
/
extconf.rb
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
#!/usr/bin/ruby
ARGV.collect! {|x| x.sub(/^--with-mmap-prefix=/, "--with-mmap-dir=") }
require 'mkmf'
if unknown = enable_config("unknown")
libs = if CONFIG.key?("LIBRUBYARG_STATIC")
Config::expand(CONFIG["LIBRUBYARG_STATIC"].dup).sub(/^-l/, '')
else
Config::expand(CONFIG["LIBRUBYARG"].dup).sub(/^lib([^.]*).*/, '\\1')
end
unknown = find_library(libs, "ruby_init",
Config::expand(CONFIG["archdir"].dup))
end
dir_config("mmap")
if enable_config("ipc")
unless have_func("semctl") && have_func("shmctl")
$stderr.puts "\tIPC will not be available"
end
end
$CFLAGS += " -DRUBYLIBDIR='\"#{CONFIG['rubylibdir']}\"'"
create_makefile "mmap"
begin
make = open("Makefile", "a")
make.puts "\ntest: $(DLLIB)"
Dir.foreach('test') do |x|
next if /^\./ =~ x || /(_\.rb|~)$/ =~ x
next if FileTest.directory?(x)
make.print "\truby test/#{x}\n"
end
if unknown
make.print <<-EOT
unknown: $(DLLIB)
\t@echo "main() {}" > /tmp/a.c
\t$(CC) -static /tmp/a.c $(OBJS) $(CPPFLAGS) $(DLDFLAGS) $(LIBS) $(LOCAL_LIBS)
\t@-rm /tmp/a.c a.out
EOT
end
make.print <<-EOT
%.html: %.rd
\trd2 $< > ${<:%.rd=%.html}
EOT
make.print "HTML = mmap.html"
doc = Dir['doc/*.rd']
doc.each {|x| make.print " \\\n\t#{x.sub(/\.rd$/, '.html')}" }
make.print "\n\nRDOC = doc/mmap.rb"
make.puts
make.print <<-EOF
rdoc: doc/doc/index.html
doc/doc/index.html: $(RDOC)
\t@-(cd doc; rdoc mmap.rb)
ri: doc/mmap.rb
\t@-(cd doc; rdoc -r mmap.rb)
ri-site: doc/mmap.rb
\t@-(cd doc; rdoc -R mmap.rb)
rd2: html
html: $(HTML)
EOF
ensure
make.close
end