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))
|
|
|
|
|
2002-03-14 08:10:57 -05:00
|
|
|
if have_header("iconv.h")
|
2003-07-29 21:31:43 -04:00
|
|
|
if !try_compile("", "-Werror") or checking_for("iconv() 2nd argument is const") do
|
|
|
|
!try_compile('
|
|
|
|
#include <iconv.h>
|
|
|
|
size_t
|
|
|
|
test(iconv_t cd, char **inptr, size_t *inlen, char **outptr, size_t *outlen)
|
|
|
|
{
|
|
|
|
return iconv(cd, inptr, inlen, outptr, outlen);
|
|
|
|
}
|
|
|
|
', "-Werror")
|
|
|
|
end
|
|
|
|
$defs.push('-DICONV_INPTR_CAST=""')
|
|
|
|
else
|
|
|
|
$defs.push('-DICONV_INPTR_CAST="(char **)"')
|
|
|
|
end
|
2004-01-27 01:05:04 -05:00
|
|
|
have_library("iconv", "iconv")
|
2003-07-18 15:51:42 -04:00
|
|
|
if conf
|
|
|
|
prefix = '$(srcdir)'
|
|
|
|
prefix = $nmake ? "{#{prefix}}" : "#{prefix}/"
|
2004-01-13 23:31:11 -05:00
|
|
|
wrapper = "./iconv.rb"
|
|
|
|
$INSTALLFILES = [[wrapper, "$(RUBYARCHDIR)"]]
|
2003-07-18 15:51:42 -04:00
|
|
|
if String === conf
|
|
|
|
require 'uri'
|
|
|
|
scheme = URI.parse(conf).scheme
|
|
|
|
else
|
|
|
|
conf = prefix + "config.charset"
|
|
|
|
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
|
|
|
|
mf.print("\n\t$(RUBY) ", prefix, "charset_alias.rb ", conf, " $@\n")
|
|
|
|
end
|
|
|
|
end
|
2002-03-14 08:10:57 -05:00
|
|
|
end
|