summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2012-11-06 04:36:38 -0800
committerAndreas Maunz <andreas@maunz.de>2012-11-06 04:36:38 -0800
commit9fc23ed4edf0eb8f3738fd703bffd677bc69b84a (patch)
treedbb14737019af6fb03ef95f3508e3949a9017e96
parent1a2b3ed44aece3421b0c557032a3159f3345cc89 (diff)
parent627f8e06c306711df784e877b683e40c22bb7571 (diff)
Merge pull request #2 from ktns/macosx
Installation problem on MacOSX
-rw-r--r--.gitignore1
-rw-r--r--ext/openbabel/Makefile8
-rw-r--r--ext/openbabel/extconf.rb27
-rw-r--r--openbabel.gemspec2
4 files changed, 19 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index 4040c6c..9eb254e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
*.gem
.bundle
Gemfile.lock
+Makefile
pkg/*
diff --git a/ext/openbabel/Makefile b/ext/openbabel/Makefile
deleted file mode 100644
index 581ad59..0000000
--- a/ext/openbabel/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-.PHONY: openbabel.so
-openbabel.so:
- chmod 755 openbabel.so
-
-.PHONY: install
-install:
- mkdir -p ../../lib/openbabel
- mv openbabel.so ../../lib/openbabel
diff --git a/ext/openbabel/extconf.rb b/ext/openbabel/extconf.rb
index 98150ea..e0dfbae 100644
--- a/ext/openbabel/extconf.rb
+++ b/ext/openbabel/extconf.rb
@@ -1,5 +1,6 @@
require 'fileutils'
require 'tmpdir'
+require 'mkmf'
ob_num_ver="2.3.1"
ob_ver="openbabel-"+ob_num_ver
@@ -19,13 +20,7 @@ begin
Dir.chdir ob_main_dir do
puts "Configuring OpenBabel"
puts `cmake #{ob_main_dir} -DCMAKE_INSTALL_PREFIX=#{lib_dir}`
- openbabel_libs = false
- openbabel_libs = true if `/sbin/ldconfig -p`.split("\n").grep(/openbabel/)
- unless openbabel_libs
- ENV["LD_LIBRARY_PATH"].split(":").each do |dir|
- openbabel_libs = true unless Dir[File.join(dir,"*libopenbabel*")].empty?
- end
- end
+ openbabel_libs = have_library('openbabel')
unless openbabel_libs
puts "OpenBabel not installed. Compiling sources."
puts `make`
@@ -34,15 +29,27 @@ begin
end
Dir.chdir ob_bindings_dir do
puts "Compiling and instaling OpenBabel Ruby bindings."
- `sed -i 's/Init_OpenBabel/Init_openbabel/g' *cpp`
+ `sed -i -e 's/Init_OpenBabel/Init_openbabel/g' *cpp`
# get include and lib from pkg-config
ob_include=`pkg-config openbabel-2.0 --cflags-only-I`.sub(/\s+/,'').sub(/-I/,'')
ob_lib=`pkg-config openbabel-2.0 --libs-only-L`.sub(/\s+/,'').sub(/-L/,'')
`ruby extconf.rb --with-openbabel-include=#{ob_include} --with-openbabel-lib=#{ob_lib}`
- `sed -i 's/-flat_namespace//' Makefile`
+ `sed -i -e 's/-flat_namespace//' Makefile`
puts `make`
end
- FileUtils.cp(ob_bindings_dir+"/openbabel.so", "./")
+ FileUtils.cp(ob_bindings_dir+"/openbabel.#{RbConfig::CONFIG["DLEXT"]}", "./")
+ File.open('Makefile', 'w') do |makefile|
+ makefile.write <<"EOF"
+.PHONY: openbabel.#{RbConfig::CONFIG["DLEXT"]}
+openbabel.#{RbConfig::CONFIG["DLEXT"]}:
+ chmod 755 openbabel.#{RbConfig::CONFIG["DLEXT"]}
+
+.PHONY: install
+install:
+ mkdir -p ../../lib/openbabel
+ mv openbabel.#{RbConfig::CONFIG["DLEXT"]} ../../lib/openbabel
+EOF
+ end
ensure
FileUtils.remove_entry_secure main_dir
end
diff --git a/openbabel.gemspec b/openbabel.gemspec
index dc74fa2..3441b95 100644
--- a/openbabel.gemspec
+++ b/openbabel.gemspec
@@ -12,6 +12,6 @@ Gem::Specification.new do |s|
s.summary = %q{OpenBabel!}
s.test_files = ["test/test_openbabel.rb"]
- s.files = ["Rakefile", "lib/openbabel.rb", "ext/openbabel/Makefile"]
+ s.files = ["Rakefile", "lib/openbabel.rb"]
s.extensions = ['ext/openbabel/extconf.rb']
end