File: extconf.rb

package info (click to toggle)
openbabel 2.4.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 58,308 kB
  • sloc: cpp: 459,210; ansic: 90,514; php: 13,963; python: 7,899; perl: 6,518; pascal: 793; sh: 179; xml: 97; ruby: 64; makefile: 46; java: 23; cs: 14
file content (53 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download | duplicates (5)
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
# Creates a makefile to build the Open Babel-Ruby extension.

# Compensate for the fact that Ruby will try to build universal
# binaries on OS X by default
require 'rbconfig'
if RbConfig::CONFIG["arch"] =~ /universal-darwin/
  ENV['ARCHFLAGS'] = case `uname -smr`.chomp
    when "i386" then '-arch i386'
    when "ppc"  then '-arch ppc'
  end
  isDarwin = true
else
  isDarwin = false
end

require 'mkmf'

dir_config('openbabel')

# Find a trivial header in order to add the proper include path
# to the build flags.
here = File.dirname(__FILE__)
find_header('inchi_api.h', '/usr/include/inchi', '/usr/include', here + '/../../include')

# Prevent Ruby 1.8.x from trying to compile and link the extension
# using gcc.
if RUBY_VERSION < "1.9"
  cxx = ''
  begin
    File.open('../Makefile', 'r').each_line do |line|
      if line =~ /CXX = /
        cxx = Regexp.last_match.post_match.chomp
      end
    end
  rescue Errno::ENOENT
    puts 'Please configure Open Babel before compiling the Ruby extension'
  end
  cpp_command(cxx)
end

if have_library('openbabel')
  if isDarwin
    with_ldflags("#$LDFLAGS -dynamic --flat-namespace") do #Enables cc to handle linking better.
    create_makefile('openbabel')
    end
  else
    with_ldflags("#$LDFLAGS -dynamic") do #Enables cc to handle linking better.
    create_makefile('openbabel')
    end
  end
else
  puts "Install Open Babel first. If you've already compiled and installed Open Babel, you may need to run ldconfig."
end