require 'mkmf' # If your MySQL is not installed in C:\Program Files\Mysql\Mysql Server 4.1 # change this to match your system. I used the 8.3 names to get rid of spaces. mysql_dir = "c:\\progra~1\\mysql\\MYSQLS~1.1" # Check the 8.3 pathname below and make certain it's the # same on your system. This is setup to use VC6. If you # want to use VC7, change it to the 8.3 for VC7 vc_dir = "c:\\progra~1\\MIAF9D~1\\vc98" # vc_dir = "c:\\progra~1\\MICROS~2.NET\\vc7" ###### You should not need to change anything below this line ###### inc, lib = dir_config("mysql", mysql_dir) $LIBPATH[0] = "#{mysql_dir}\\lib\\opt" pinc, plib = dir_config("vc", vc_dir) if vc_dir =~ /vc7/i dir_config("sdk", vc_dir + "\\PLATFO~1") end puts $LIBPATH.inspect have_library("libmysql") have_func("mysql_ssl_set") if have_header('mysql.h') then src = "#include \n#include \n" elsif have_header('mysql/mysql.h') then src = "#include \n#include \n" else exit 1 end src += "int main() {}" File::open("conftest.c", "w") do |f| f.puts src end if defined? cpp_command then cpp = Config::expand(cpp_command('')) else cpp = Config::expand sprintf(CPP, $CPPFLAGS, $CFLAGS, '') end unless system "#{cpp} > confout" then exit 1 end File::unlink "conftest.c" error_syms = [] IO::foreach('confout') do |l| next unless l =~ /errmsg\.h|mysqld_error\.h/ fn = l.split(/\"/)[1] IO::foreach(fn) do |m| if m =~ /^#define\s+([CE]R_[0-9A-Z_]+)/ then error_syms << $1 end end end File::unlink 'confout' error_syms.uniq! newf = File::open('mysql.c', 'w') IO::foreach('mysql.c.in') do |l| newf.puts l if l =~ /\/\* Mysql::Error constant \*\// then error_syms.each do |s| newf.puts " rb_define_const(eMysql, \"#{s}\", INT2NUM(#{s}));" end end end create_makefile("mysql")