Created
January 8, 2011 19:31
-
-
Save baoilleach/771081 to your computer and use it in GitHub Desktop.
extconf.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's part of extconf.rb from OB after some edits to add support for --prefix. Unfortunately, this doesn't work (see discussion of mkmf2 which tries to fix some of these problems) | |
require 'getoptlong' | |
makeopts = {} | |
opts = GetoptLong.new(["--prefix", "-p", GetoptLong::OPTIONAL_ARGUMENT], | |
["--with-openbabel-lib", "-L", GetoptLong::OPTIONAL_ARGUMENT], | |
["--with-openbabel-include", "-I", GetoptLong::OPTIONAL_ARGUMENT] | |
).each{|o, a| makeopts[o[%r/[^-].*/]] = a} | |
prefix = makeopts.delete('prefix') || nil | |
oblib = makeopts.delete('with-openbabel-lib') || nil | |
obinclude = makeopts.delete('with-openbabel-include') || nil | |
ARGV.push "--with-openbabel-lib=#{oblib}" | |
ARGV.push "--with-openbabel-include=#{obinclude}" | |
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') | |
with_ldflags("#$LDFLAGS -dynamic -flat_namespace") do #Enables cc to handle linking better. | |
create_makefile('openbabel') | |
end | |
else | |
puts "Install Open Babel first. If you've already compiled and installed Open Babel, you may need to run ldconfig." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment