~ubuntu-branches/ubuntu/trusty/libodbc-ruby/trusty

« back to all changes in this revision

Viewing changes to .pc/001extconf_dlopen.patch/ext/extconf.rb

  • Committer: Bazaar Package Importer
  • Author(s): Daigo Moriwaki, Lucas Nussbaum
  • Date: 2010-05-07 16:50:04 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100507165004-so71tlp4aaqvwa69
Tags: 0.99991-1
* New upstream release
* Switch to dpkg-source 3.0 (quilt) format
  + Added debian/source
* Bumped Standard Version to 3.8.4
* Updated debian/patches
  + Added quilt patch, removed dpatch
    because upstream has new directory structure
* Updated .example. no test.rb is available with new release
* Updated debian/control
  + Added Build-Depends for ruby1.9.1
  + Removed dpatch from Build-Depends
  + Added myself to Uploaders
* Updated debian/rules
  + Port to ruby1.9.1 (Closes: #507695)
  + Changed the directory structure for make
  + Removed dpatch.mk

[ Lucas Nussbaum ]
* Fixed Vcs-* fields after pkg-ruby-extras SVN layout change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'mkmf'
 
2
 
 
3
if ! defined? PLATFORM
 
4
  PLATFORM = RUBY_PLATFORM
 
5
end
 
6
 
 
7
def have_library_ex(lib, func="main", headers=nil)
 
8
  checking_for "#{func}() in -l#{lib}" do
 
9
    libs = append_library($libs, lib)
 
10
    if !func.nil? && !func.empty? && COMMON_LIBS.include?(lib)
 
11
      true
 
12
    elsif try_func(func, libs, headers)
 
13
      $libs = libs
 
14
      true
 
15
    else
 
16
      false
 
17
    end
 
18
  end
 
19
end
 
20
 
 
21
dir_config("odbc")
 
22
have_header("version.h")
 
23
have_header("sql.h") || begin
 
24
  puts "ERROR: sql.h not found"
 
25
  exit 1
 
26
end
 
27
have_header("sqlext.h") || begin
 
28
  puts "ERROR: sqlext.h not found"
 
29
  exit 1
 
30
end
 
31
testdlopen = enable_config("dlopen", true)
 
32
begin
 
33
  if PLATFORM !~ /(mingw|cygwin)/ then
 
34
    header = "sqltypes.h"
 
35
  else
 
36
    header = ["windows.h", "sqltypes.h"]
 
37
  end
 
38
  if defined? have_type
 
39
    have_type("SQLTCHAR", header)
 
40
  else
 
41
    throw
 
42
  end
 
43
rescue
 
44
  puts "WARNING: please check sqltypes.h for SQLTCHAR manually,"
 
45
  puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
 
46
  puts "WARNING: the option -DHAVE_TYPE_SQLTCHAR"
 
47
end
 
48
begin
 
49
  if PLATFORM !~ /(mingw|cygwin)/ then
 
50
    header = "sqltypes.h"
 
51
  else
 
52
    header = ["windows.h", "sqltypes.h"]
 
53
  end
 
54
  if defined? have_type
 
55
    have_type("SQLLEN", header)
 
56
  else
 
57
    throw
 
58
  end
 
59
rescue
 
60
  puts "WARNING: please check sqltypes.h for SQLLEN manually,"
 
61
  puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
 
62
  puts "WARNING: the option -DHAVE_TYPE_SQLLEN"
 
63
end
 
64
begin
 
65
  if PLATFORM !~ /(mingw|cygwin)/ then
 
66
    header = "sqltypes.h"
 
67
  else
 
68
    header = ["windows.h", "sqltypes.h"]
 
69
  end
 
70
  if defined? have_type
 
71
    have_type("SQLULEN", header)
 
72
  else
 
73
    throw
 
74
  end
 
75
rescue
 
76
  puts "WARNING: please check sqltypes.h for SQLULEN manually,"
 
77
  puts "WARNING: if defined, modify CFLAGS in Makefile to contain"
 
78
  puts "WARNING: the option -DHAVE_TYPE_SQLULEN"
 
79
end
 
80
$have_odbcinst_h = have_header("odbcinst.h")
 
81
 
 
82
if PLATFORM =~ /mswin32/ then
 
83
  if !have_library_ex("odbc32", "SQLAllocConnect", "sql.h") ||
 
84
     !have_library_ex("odbccp32", "SQLConfigDataSource", "odbcinst.h") ||
 
85
     !have_library_ex("odbccp32", "SQLInstallerError", "odbcinst.h") ||
 
86
     !have_library("user32", "CharUpper") then
 
87
    puts "Can not locate odbc libraries"
 
88
    exit 1
 
89
  end
 
90
  have_func("SQLInstallerError", "odbcinst.h")
 
91
# mingw untested !!!
 
92
elsif PLATFORM =~ /(mingw|cygwin)/ then
 
93
  have_library("odbc32", "")
 
94
  have_library("odbccp32", "")
 
95
  have_library("user32", "")
 
96
elsif (testdlopen && PLATFORM !~ /(macos|darwin)/ && CONFIG["CC"] =~ /gcc/ && have_func("dlopen", "dlfcn.h") && have_library("dl", "dlopen")) then
 
97
  $LDFLAGS+=" -Wl,-init -Wl,ruby_odbc_init -Wl,-fini -Wl,ruby_odbc_fini"
 
98
  $CPPFLAGS+=" -DHAVE_SQLCONFIGDATASOURCE"
 
99
  $CPPFLAGS+=" -DHAVE_SQLINSTALLERERROR"
 
100
  $CPPFLAGS+=" -DUSE_DLOPEN_FOR_ODBC_LIBS"
 
101
  if defined? have_type then
 
102
    if have_type("SQLBIGINT", "sqltypes.h", "-DHAVE_LONG_LONG") then
 
103
      $CPPFLAGS+=" -DHAVE_LONG_LONG"
 
104
    end
 
105
  end
 
106
else
 
107
  have_library("odbc", "SQLAllocConnect") ||
 
108
    have_library("iodbc", "SQLAllocConnect")
 
109
  ($have_odbcinst_h &&
 
110
    have_library("odbcinst", "SQLConfigDataSource")) ||
 
111
  ($have_odbcinst_h &&
 
112
    have_library("iodbcinst", "SQLConfigDataSource"))
 
113
  $have_odbcinst_h &&
 
114
    have_func("SQLInstallerError", "odbcinst.h")
 
115
  if defined? have_type then
 
116
    if have_type("SQLBIGINT", "sqltypes.h", "-DHAVE_LONG_LONG") then
 
117
      $CPPFLAGS+=" -DHAVE_LONG_LONG"
 
118
    end
 
119
  end
 
120
end
 
121
 
 
122
create_makefile("odbc")