#!/usr/bin/env ruby require 'rbconfig' def method_missing(s, *args) if v = Config::CONFIG[s] || Config::CONFIG[s.upcase] return v else puts "missing: #{s}" super end end if RUBY_PLATFORM =~ /win32/ # FIXME: Make more robust # We can't use Ruby's standard build procedures # on Windows because the Ruby executable is # built with VC++ while here we want to build # with MingW. So just roll our own... target = "libxml" #RUBY_INCLUDE_DIR = Config::CONFIG["archdir"] #RUBY_BIN_DIR = Config::CONFIG["bindir"] #RUBY_LIB_DIR = Config::CONFIG["libdir"] #RUBY_SHARED_LIB = Config::CONFIG["LIBRUBY"] #RUBY_SHARED_DLL = RUBY_SHARED_LIB.gsub(/lib$/, 'dll') #CLEAN.include('*.o') #CLOBBER.include('ruby_prof.so') srcs = Dir['../ext/*.c'] objs = srcs.collect do |srcfile| srcfile = File.basename(srcfile) srcfile.chomp(File.extname(srcfile) + '.o') end #srcs.each do |srcfile| # srcfile = File.basename(srcfile) # objfile = srcfile.chomp(File.extname(srcfile) + '.o') # # if File.mtime(objfile) < File.mtime(srcfile) # system "gcc -c -fPIC -O2 -Wall -o #{objfile} #{srcfile} -I#{RUBY_INCLUDE_DIR}" # end #end #system "gcc -shared -o #{LIBNAME} #{obj} #{RUBY_BIN_DIR}/#{RUBY_SHARED_DLL}" makefile_template = DATA.read makefile = eval(makefile_template) File.open('Makefile', 'w'){ |f| f << makefile } else require 'mkmf' if defined?(CFLAGS) if CFLAGS.index(CONFIG['CCDLFLAGS']) $CFLAGS = CFLAGS else $CFLAGS = CFLAGS + ' ' + CONFIG['CCDLFLAGS'] end else $CFLAGS = CONFIG['CFLAGS'] end $LDFLAGS = CONFIG['LDFLAGS'] $LIBPATH.push(Config::CONFIG['libdir']) def crash(str) printf(" extconf failure: %s\n", str) exit 1 end dir_config('iconv') dir_config('xml2') dir_config('zlib') have_library('socket','socket') have_library('nsl','gethostbyname') unless have_library('m', 'atan') # try again for gcc 4.0 saveflags = $CFLAGS $CFLAGS += ' -fno-builtin' unless have_library('m', 'atan') crash('need libm') end $CFLAGS = saveflags end unless have_library('z', 'inflate') or have_library('zlib', 'inflate') or have_library('zlib1', 'inflate') crash('need zlib') else $defs.push('-DHAVE_ZLIB_H') end unless have_library('iconv','iconv_open') or have_library('iconv','libiconv_open') or have_library('libiconv', 'libiconv_open') or have_library('libiconv', 'iconv_open') or have_library('c','iconv_open') or have_library('recode','iconv_open') or have_library('iconv') crash(<