diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-11-06 04:36:38 -0800 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-11-06 04:36:38 -0800 |
commit | 9fc23ed4edf0eb8f3738fd703bffd677bc69b84a (patch) | |
tree | dbb14737019af6fb03ef95f3508e3949a9017e96 /ext/openbabel/extconf.rb | |
parent | 1a2b3ed44aece3421b0c557032a3159f3345cc89 (diff) | |
parent | 627f8e06c306711df784e877b683e40c22bb7571 (diff) |
Merge pull request #2 from ktns/macosx
Installation problem on MacOSX
Diffstat (limited to 'ext/openbabel/extconf.rb')
-rw-r--r-- | ext/openbabel/extconf.rb | 27 |
1 files changed, 17 insertions, 10 deletions
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 |