diff --git a/README.txt b/README.txt index 6f75aab..3bd09a5 100644 --- a/README.txt +++ b/README.txt @@ -50,6 +50,11 @@ Simply do the following, after installing MATLAB: * ruby setup.rb setup * ruby setup.rb install +If you are using OSX please make sure your Matlab paths are the same as the ones in the ext/matlab_api/extconf.rb file and add the following two lines to your ~/.bash_profile file: + +export PATH=/Applications/MATLAB_R2012a.app/bin:$PATH +export DYLD_LIBRARY_PATH=/Applications/MATLAB_R2012a.app/bin/maci64:$DYLD_LIBRARY_PATH + Alternatively, you can download and install the RubyGem package for matlab-ruby (you must have RubyGems and MATLAB installed, first): diff --git a/ext/matlab_api/extconf.rb b/ext/matlab_api/extconf.rb index acea90a..d20250c 100644 --- a/ext/matlab_api/extconf.rb +++ b/ext/matlab_api/extconf.rb @@ -3,9 +3,26 @@ SWIG_WRAP = "matlab_api_wrap.c" -matlab_dirs = dir_config( "matlab", "/usr/local/matlab/extern/include", "/usr/local/matlab/bin/glnx86" ) +case RbConfig::CONFIG['host_os'] + when /mswin|windows/ + # Windows - Who cares + when /linux|arch/ + if RbConfig::CONFIG['host_cpu'] =~ /x86_64/ + matlab_dirs = dir_config( "matlab", "/usr/local/matlab/extern/include", "/usr/local/matlab/bin/glnxa64" ) + else + matlab_dirs = dir_config( "matlab", "/usr/local/matlab/extern/include", "/usr/local/matlab/bin/glnx86" ) + end + when /darwin/ + if RbConfig::CONFIG['host_cpu'] =~ /x86_64/ + matlab_dirs = dir_config( "/Applications/MATLAB_R2012a.app/bin/matlab", "/Applications/MATLAB_R2012a.app/extern/include", "/Applications/MATLAB_R2012a.app/bin/maci64" ) + else + matlab_dirs = dir_config( "/Applications/MATLAB_R2012a.app/bin/matlab", "/Applications/MATLAB_R2012a.app/extern/include", "/Applications/MATLAB_R2012a.app/bin/maci" ) + end + else + puts "Architecture Not Found, Please edit PATH variable in extconf.rb" +end -if have_header( "engine.h" ) && have_library( "eng", "engOpen" ) +if have_header( "engine.h" ) && have_library( "eng", "engOpen" ) if !File.exists?( SWIG_WRAP ) || with_config( "swig", false ) swig_includes = (matlab_dirs.any? ? (matlab_dirs.collect { |dir| "-I#{dir}" }.join(" ")) : nil) puts "creating #{SWIG_WRAP}" diff --git a/setup.rb b/setup.rb index 5f22fc1..9f9d458 100644 --- a/setup.rb +++ b/setup.rb @@ -102,7 +102,7 @@ def multipackage_install? class ConfigTable - c = ::Config::CONFIG + c = RbConfig::CONFIG rubypath = c['bindir'] + '/' + c['ruby_install_name'] @@ -1219,7 +1219,7 @@ def ruby_extentions(dir) raise InstallError, "no ruby extention exists: 'ruby #{$0} setup' first" end - DLEXT = /\.#{ ::Config::CONFIG['DLEXT'] }\z/ + DLEXT = /\.#{ RbConfig::CONFIG['DLEXT'] }\z/ def _ruby_extentions(dir) Dir.open(dir) {|d|