2009-12-14 17:15:00 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class RubyOdbc < Formula
|
|
|
|
homepage 'http://www.ch-werner.de/rubyodbc/'
|
2013-03-30 16:28:01 +00:00
|
|
|
url 'http://www.ch-werner.de/rubyodbc/ruby-odbc-0.99995.tar.gz'
|
|
|
|
sha1 '8fc7bd34c582953e56478050a7b41b4b3e0efdd3'
|
2009-12-14 17:15:00 +00:00
|
|
|
|
|
|
|
depends_on 'unixodbc'
|
|
|
|
depends_on 'freetds'
|
|
|
|
|
|
|
|
def install
|
|
|
|
# extconf.rb assumes it will install ruby-odbc within a folder in your
|
|
|
|
# current ruby installation.
|
2010-03-10 19:06:16 +00:00
|
|
|
system "ruby", "-Cext", "extconf.rb", "--enable-dlopen", "--with-odbc-dir=#{HOMEBREW_PREFIX}/lib"
|
|
|
|
|
2009-12-14 17:15:00 +00:00
|
|
|
# The following modifications to the Makefile ensure that it is installed
|
|
|
|
# within your homebrew directories.
|
2010-03-10 19:06:16 +00:00
|
|
|
inreplace 'ext/Makefile' do |s|
|
2010-02-15 22:46:58 +00:00
|
|
|
s.change_make_var! "prefix", prefix
|
|
|
|
s.change_make_var! "sitearchdir", lib
|
2010-03-10 19:06:16 +00:00
|
|
|
|
2011-03-18 17:30:47 +00:00
|
|
|
if MacOS.prefer_64_bit?
|
2010-03-10 19:06:16 +00:00
|
|
|
# ruby-odbc still chooses iODBC over unixODBC (even with --with-odbc-dir)
|
|
|
|
# apparently because unixODBC is compiled for only x86_64 and ruby-odbc
|
|
|
|
# and iODBC are both i386 and x86_64. The solution (which works for me on Snow Leopard)
|
|
|
|
# is to remove i386 references from ruby-odbc's makefile. YMMV.
|
|
|
|
s.change_make_var! "CFLAGS", "-fno-common -arch x86_64 -g -Os -pipe -DENABLE_DTRACE $(cflags)"
|
|
|
|
s.change_make_var! "ldflags", "-L. -arch x86_64"
|
|
|
|
s.change_make_var! "LDSHARED", "cc -arch x86_64 -pipe -bundle -undefined dynamic_lookup"
|
|
|
|
s.change_make_var! "LIBS", "$(LIBRUBYARG_SHARED) -lodbcinst -lodbc -lpthread -ldl"
|
|
|
|
end
|
2010-02-15 22:46:58 +00:00
|
|
|
end
|
2009-12-14 17:15:00 +00:00
|
|
|
|
2010-03-10 19:06:16 +00:00
|
|
|
lib.mkpath
|
|
|
|
system 'make -C ext'
|
|
|
|
system 'make -C ext install'
|
2009-12-14 17:15:00 +00:00
|
|
|
end
|
|
|
|
|
2009-12-19 15:36:20 +00:00
|
|
|
def caveats; <<-EOS
|
|
|
|
Installed #{lib}/odbc.bundle
|
2009-12-14 17:15:00 +00:00
|
|
|
|
|
|
|
You will need to add this to your RUBYLIB by adding the following line to
|
2009-12-19 15:36:20 +00:00
|
|
|
.profile or .bashrc or equivalent:
|
2009-12-14 17:15:00 +00:00
|
|
|
|
2009-12-19 15:36:20 +00:00
|
|
|
export RUBYLIB="#{HOMEBREW_PREFIX}/lib:$RUBYLIB"
|
|
|
|
|
|
|
|
You will need to edit freetds.conf, odbcinst.ini and odbc.ini files to set up
|
2009-12-14 17:15:00 +00:00
|
|
|
access to your odbc databases.
|
2009-12-19 15:36:20 +00:00
|
|
|
EOS
|
2009-12-14 17:15:00 +00:00
|
|
|
end
|
|
|
|
end
|