2002-03-14 08:10:57 -05:00
|
|
|
require 'mkmf'
|
|
|
|
|
|
|
|
dir_config("iconv")
|
|
|
|
|
2003-07-18 15:51:42 -04:00
|
|
|
conf = File.exist?(File.join($srcdir, "config.charset"))
|
|
|
|
conf = with_config("config-charset", enable_config("config-charset", conf))
|
|
|
|
|
2004-06-25 02:33:11 -04:00
|
|
|
if have_func("iconv", "iconv.h") or
|
2005-11-06 09:08:56 -05:00
|
|
|
have_library("iconv", "iconv", "iconv.h")
|
2004-02-15 22:29:16 -05:00
|
|
|
if checking_for("const of iconv() 2nd argument") do
|
|
|
|
create_tmpsrc(cpp_include("iconv.h") + "---> iconv(cd,0,0,0,0) <---")
|
|
|
|
src = xpopen(cpp_command("")) {|f|f.read}
|
|
|
|
if !(func = src[/^--->\s*(\w+).*\s*<---/, 1])
|
|
|
|
Logging::message "iconv function name not found"
|
|
|
|
false
|
|
|
|
elsif !(second = src[%r"\b#{func}\s*\(.*?,(.*?),.*?\)\s*;"m, 1])
|
|
|
|
Logging::message "prototype for #{func}() not found"
|
|
|
|
false
|
|
|
|
else
|
|
|
|
Logging::message $&+"\n"
|
|
|
|
/\bconst\b/ =~ second
|
|
|
|
end
|
2003-07-29 21:31:43 -04:00
|
|
|
end
|
2005-09-09 03:45:36 -04:00
|
|
|
$defs.push('-DICONV_INPTR_CONST')
|
2003-07-29 21:31:43 -04:00
|
|
|
end
|
2004-02-15 22:29:16 -05:00
|
|
|
have_func("iconvlist", "iconv.h")
|
2007-12-05 11:04:12 -05:00
|
|
|
have_func("__iconv_free_list", "iconv.h")
|
2003-07-18 15:51:42 -04:00
|
|
|
if conf
|
|
|
|
prefix = '$(srcdir)'
|
|
|
|
prefix = $nmake ? "{#{prefix}}" : "#{prefix}/"
|
2005-10-13 10:33:30 -04:00
|
|
|
if $extout
|
|
|
|
wrapper = "$(RUBYARCHDIR)/iconv.rb"
|
|
|
|
else
|
|
|
|
wrapper = "./iconv.rb"
|
|
|
|
$INSTALLFILES = [[wrapper, "$(RUBYARCHDIR)"]]
|
|
|
|
end
|
2003-07-18 15:51:42 -04:00
|
|
|
if String === conf
|
|
|
|
require 'uri'
|
|
|
|
scheme = URI.parse(conf).scheme
|
|
|
|
else
|
2005-10-08 06:15:50 -04:00
|
|
|
conf = "$(srcdir)/config.charset"
|
2003-07-18 15:51:42 -04:00
|
|
|
end
|
2003-12-13 04:55:21 -05:00
|
|
|
$cleanfiles << wrapper
|
2003-07-18 15:51:42 -04:00
|
|
|
end
|
2002-03-14 08:10:57 -05:00
|
|
|
create_makefile("iconv")
|
2003-07-18 15:51:42 -04:00
|
|
|
if conf
|
|
|
|
open("Makefile", "a") do |mf|
|
2003-12-13 04:55:21 -05:00
|
|
|
mf.print("\nall: #{wrapper}\n\n#{wrapper}: #{prefix}charset_alias.rb")
|
2003-07-18 15:51:42 -04:00
|
|
|
mf.print(" ", conf) unless scheme
|
2005-10-08 06:15:50 -04:00
|
|
|
mf.print("\n\t$(RUBY) $(srcdir)/charset_alias.rb #{conf} $@\n")
|
2003-07-18 15:51:42 -04:00
|
|
|
end
|
|
|
|
end
|
2002-03-14 08:10:57 -05:00
|
|
|
end
|