Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get the Rakefile working and building extension by finding freetds in…

…clude dir.
  • Loading branch information...
commit 8e03fcbeaa57b452b5574caf7864ddb9d45abfe5 1 parent 36f91db
@metaskills metaskills authored
Showing with 51 additions and 2 deletions.
  1. +7 −0 README.rdoc
  2. +2 −1  Rakefile
  3. +42 −1 ext/tiny_tds/extconf.rb
View
7 README.rdoc
@@ -1,13 +1,20 @@
= TinyTds
+
== Tiny Ruby Wrapper For FreeTDS
+
== Install
Install with Rubygems:
gem install tiny_tds
+From Source:
+
+ * Maybe use ruby extconf.rb --with-freetds-include=/opt/local/include/freetds
+
+
== Author
Written by Ken Collins
View
3  Rakefile
@@ -1,4 +1,5 @@
require 'rake'
+require 'rake/testtask'
require 'rake/extensiontask'
@@ -11,7 +12,7 @@ def test_files
end
-Rake::TestTask.new(profile_case) do |t|
+Rake::TestTask.new do |t|
t.libs = test_libs
t.test_files = test_files
t.verbose = true
View
43 ext/tiny_tds/extconf.rb
@@ -1,5 +1,46 @@
-# encoding: UTF-8
require 'mkmf'
+FREETDS_HEADERS = ['sqlfront.h', 'sybdb.h']
+
+dir_config('freetds')
+
+def root_paths
+ eop_regexp = /#{File::SEPARATOR}bin$/
+ paths = ENV['PATH'].split(File::PATH_SEPARATOR)
+ bin_paths = paths.select{ |p| p =~ eop_regexp }
+ bin_paths.map{ |p| p.sub(eop_regexp,'') }.compact.reject{ |p| p.empty? }
+end
+
+def have_freetds_headers(*headers)
+ headers.all? { |h| have_header(h) }
+end
+
+def find_freetds_include_path
+ root_paths.detect do |path|
+ dir = File.join path, 'include', 'freetds'
+ message = "looking for #{dir} directory..."
+ if File.directory?(dir)
+ puts "#{message} yes"
+ if with_cppflags("#{$CPPFLAGS} -I#{dir}".strip) { have_freetds_headers(*FREETDS_HEADERS) }
+ $CPPFLAGS += "#{$CPPFLAGS} -I#{dir}".strip
+ true
+ else
+ false
+ end
+ else
+ puts "#{message} no"
+ false
+ end
+ end
+end
+
+
+if have_freetds_headers(*FREETDS_HEADERS) || find_freetds_include_path
+
+else
+ abort "-----\nCan not find FreeTDS include directory.\n-----"
+end
+
+
create_makefile('tiny_tds/tiny_tds')
Please sign in to comment.
Something went wrong with that request. Please try again.