File: extconf.rb

package info (click to toggle)
libdb2-ruby 0.5.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,352 kB
  • ctags: 2,743
  • sloc: ansic: 11,156; ruby: 6,199; cpp: 6,064; makefile: 86; sh: 31
file content (120 lines) | stat: -rw-r--r-- 2,261 bytes parent folder | download | duplicates (8)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
require 'mkmf'
load './myconfig'

$DLDFLAGS ||= ""
$LDFLAGS ||= ""

def addld(key, path, lib)
   libs = if lib.kind_of?(Array)
	     "-l" + lib.join(" -l")
	  else
	     "-l#{lib}"
	  end
   if path
      case Config::CONFIG["arch"]
      when /solaris2/
	 libs = " -L#{path} -R#{path} #{libs}"
      when /linux/
	 libs = " -Wl,-rpath,#{path} -L#{path} #{libs}"
      else
	 libs = " -L#{path} #{libs}"
      end
   end
   $stderr.puts "\t#{key}\tusing ... #{libs}"
   $DLDFLAGS += " #{libs}"
   $LDFLAGS += " #{libs}"
end

$CFLAGS += " -I. -I../src"

$stderr.puts "INCLUDE"
$order.each do |key|
   val = $include[key]
   unless val.nil?
      res = if val.kind_of?(Array)
	       " -I" + val.join(" -I")
	    else
	       " -I#{val}"
	    end
      $stderr.puts "\t#{key}\tusing ... #{res}"
      $CFLAGS += res

   end
end

$CFLAGS += " -DBDB_NO_THREAD" if enable_config("thread") == false

$stderr.puts "\nLIBRARY"
$order.each do |key|
   val = $library[key]
   if val.kind_of?(Array) && val.size == 2
      addld(key, *val)
   end
end

if CONFIG["LDSHARED"] == "gcc -shared"
   CONFIG["LDSHARED"] = "g++ -shared"
end

if with_config("bdb-objs")
   bdb_obj = Dir["../src/*.#{$OBJEXT}"]
   if bdb_obj.size == 0
      puts <<-EOT

 ****************************************************
 Build bdb first, if you want to link bdbxml with bdb
 ****************************************************

      EOT
      exit
   end
   $objs = ["bdbxml.o"] + bdb_obj
   $CFLAGS += " -DBDB_LINK_OBJ"
end

create_makefile('bdbxml')

begin
   make = open("Makefile", "a")
   make.print <<-EOF

%.html: %.rd
\trd2 $< > ${<:%.rd=%.html}

   EOF
   make.print "HTML = bdbxml.html"
   docs = Dir['docs/*.rd']
   docs.each {|x| make.print " \\\n\t#{x.sub(/\.rd$/, '.html')}" }
   make.print "\n\nRDOC = bdbxml.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.glob('tests/*.rb') do |x|
      next if /(_\.rb|~)$/ =~ x
      next if FileTest.directory?(x)
      make.print "\t#{CONFIG['RUBY_INSTALL_NAME']} #{x}\n"
   end
ensure
   make.close
end