* lib/mkmf.rb (have_struct_member): moved from ext/socket/extconf.rb.
* ext/socket/extconf.rb: use macro_defined? instead of egrep_cpp. * ext/etc/extconf.rb: use have_struct_member. * ext/etc/etc.c: add prefix HAVE_ST_ to PW_ macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d76fdc013b
commit
b8ff4a843e
@ -25,6 +25,14 @@ Sun Sep 8 14:38:31 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
|||||||
|
|
||||||
* ext/*/.cvsignore: add "*.def".
|
* ext/*/.cvsignore: add "*.def".
|
||||||
|
|
||||||
|
* lib/mkmf.rb (have_struct_member): moved from ext/socket/extconf.rb.
|
||||||
|
|
||||||
|
* ext/socket/extconf.rb: use macro_defined? instead of egrep_cpp.
|
||||||
|
|
||||||
|
* ext/etc/extconf.rb: use have_struct_member.
|
||||||
|
|
||||||
|
* ext/etc/etc.c: add prefix HAVE_ST_ to PW_ macros.
|
||||||
|
|
||||||
Sun Sep 8 14:36:40 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
|
Sun Sep 8 14:36:40 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
|
||||||
|
|
||||||
* bcc32/configure.bat : Control of a message.
|
* bcc32/configure.bat : Control of a message.
|
||||||
|
@ -58,27 +58,27 @@ setup_passwd(pwd)
|
|||||||
rb_tainted_str_new2(pwd->pw_passwd),
|
rb_tainted_str_new2(pwd->pw_passwd),
|
||||||
INT2FIX(pwd->pw_uid),
|
INT2FIX(pwd->pw_uid),
|
||||||
INT2FIX(pwd->pw_gid),
|
INT2FIX(pwd->pw_gid),
|
||||||
#ifdef PW_GECOS
|
#ifdef HAVE_ST_PW_GECOS
|
||||||
rb_tainted_str_new2(pwd->pw_gecos),
|
rb_tainted_str_new2(pwd->pw_gecos),
|
||||||
#endif
|
#endif
|
||||||
rb_tainted_str_new2(pwd->pw_dir),
|
rb_tainted_str_new2(pwd->pw_dir),
|
||||||
rb_tainted_str_new2(pwd->pw_shell),
|
rb_tainted_str_new2(pwd->pw_shell),
|
||||||
#ifdef PW_CHANGE
|
#ifdef HAVE_ST_PW_CHANGE
|
||||||
INT2FIX(pwd->pw_change),
|
INT2FIX(pwd->pw_change),
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_QUOTA
|
#ifdef HAVE_ST_PW_QUOTA
|
||||||
INT2FIX(pwd->pw_quota),
|
INT2FIX(pwd->pw_quota),
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_AGE
|
#ifdef HAVE_ST_PW_AGE
|
||||||
INT2FIX(pwd->pw_age),
|
INT2FIX(pwd->pw_age),
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_CLASS
|
#ifdef HAVE_ST_PW_CLASS
|
||||||
rb_tainted_str_new2(pwd->pw_class),
|
rb_tainted_str_new2(pwd->pw_class),
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_COMMENT
|
#ifdef HAVE_ST_PW_COMMENT
|
||||||
rb_tainted_str_new2(pwd->pw_comment),
|
rb_tainted_str_new2(pwd->pw_comment),
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_EXPIRE
|
#ifdef HAVE_ST_PW_EXPIRE
|
||||||
INT2FIX(pwd->pw_expire),
|
INT2FIX(pwd->pw_expire),
|
||||||
#endif
|
#endif
|
||||||
0 /*dummy*/
|
0 /*dummy*/
|
||||||
@ -294,26 +294,26 @@ Init_etc()
|
|||||||
|
|
||||||
sPasswd = rb_struct_define("Passwd",
|
sPasswd = rb_struct_define("Passwd",
|
||||||
"name", "passwd", "uid", "gid",
|
"name", "passwd", "uid", "gid",
|
||||||
#ifdef PW_GECOS
|
#ifdef HAVE_ST_PW_GECOS
|
||||||
"gecos",
|
"gecos",
|
||||||
#endif
|
#endif
|
||||||
"dir", "shell",
|
"dir", "shell",
|
||||||
#ifdef PW_CHANGE
|
#ifdef HAVE_ST_PW_CHANGE
|
||||||
"change",
|
"change",
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_QUOTA
|
#ifdef HAVE_ST_PW_QUOTA
|
||||||
"quota",
|
"quota",
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_AGE
|
#ifdef HAVE_ST_PW_AGE
|
||||||
"age",
|
"age",
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_CLASS
|
#ifdef HAVE_ST_PW_CLASS
|
||||||
"uclass",
|
"uclass",
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_COMMENT
|
#ifdef HAVE_ST_PW_COMMENT
|
||||||
"comment",
|
"comment",
|
||||||
#endif
|
#endif
|
||||||
#ifdef PW_EXPIRE
|
#ifdef HAVE_ST_PW_EXPIRE
|
||||||
"expire",
|
"expire",
|
||||||
#endif
|
#endif
|
||||||
0);
|
0);
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
require 'mkmf'
|
require 'mkmf'
|
||||||
|
|
||||||
def etc_grep_header(field)
|
|
||||||
if egrep_cpp(field, "#include <pwd.h>\n")
|
|
||||||
$defs.push(format("-D%s", field.upcase))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
|
have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
|
||||||
a = have_func("getlogin")
|
a = have_func("getlogin")
|
||||||
b = have_func("getpwent")
|
b = have_func("getpwent")
|
||||||
c = have_func("getgrent")
|
c = have_func("getgrent")
|
||||||
if a or b or c
|
if a or b or c
|
||||||
etc_grep_header("pw_gecos")
|
have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
|
||||||
etc_grep_header("pw_change")
|
have_struct_member('struct passwd', 'pw_change', 'pwd.h')
|
||||||
etc_grep_header("pw_quota")
|
have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
|
||||||
etc_grep_header("pw_age")
|
have_struct_member('struct passwd', 'pw_age', 'pwd.h')
|
||||||
etc_grep_header("pw_class")
|
have_struct_member('struct passwd', 'pw_class', 'pwd.h')
|
||||||
etc_grep_header("pw_comment") unless /cygwin/ === RUBY_PLATFORM
|
have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
|
||||||
etc_grep_header("pw_expire")
|
have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
|
||||||
create_makefile("etc")
|
create_makefile("etc")
|
||||||
end
|
end
|
||||||
|
@ -2,42 +2,6 @@ require 'mkmf'
|
|||||||
|
|
||||||
$CPPFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"
|
$CPPFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"
|
||||||
|
|
||||||
def have_struct_member(type, member, header=nil)
|
|
||||||
#printf "checking for %s.%s... ", type, member
|
|
||||||
#STDOUT.flush
|
|
||||||
|
|
||||||
libs = $libs
|
|
||||||
src =
|
|
||||||
if /mswin32|mingw/ =~ RUBY_PLATFORM
|
|
||||||
r = <<"SRC"
|
|
||||||
#include <windows.h>
|
|
||||||
#include <winsock.h>
|
|
||||||
SRC
|
|
||||||
else
|
|
||||||
""
|
|
||||||
end
|
|
||||||
unless header.nil?
|
|
||||||
header = [header] unless header.kind_of? Array
|
|
||||||
header.each {|h|
|
|
||||||
src << <<"SRC"
|
|
||||||
#include <#{h}>
|
|
||||||
SRC
|
|
||||||
}
|
|
||||||
end
|
|
||||||
src << <<"SRC"
|
|
||||||
int main() { return 0; }
|
|
||||||
int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
|
|
||||||
SRC
|
|
||||||
r = try_link(src, libs) # xxx try_compile is not available.
|
|
||||||
unless r
|
|
||||||
#print "no\n"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
$defs.push(format("-DHAVE_ST_%s", member.upcase))
|
|
||||||
#print "yes\n"
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
case RUBY_PLATFORM
|
case RUBY_PLATFORM
|
||||||
when /bccwin32/
|
when /bccwin32/
|
||||||
test_func = "WSACleanup"
|
test_func = "WSACleanup"
|
||||||
@ -48,10 +12,7 @@ when /mswin32|mingw/
|
|||||||
have_library("wsock32", "WSACleanup")
|
have_library("wsock32", "WSACleanup")
|
||||||
have_func("closesocket")
|
have_func("closesocket")
|
||||||
when /cygwin/
|
when /cygwin/
|
||||||
# $LDFLAGS << " -L/usr/lib" if File.directory?("/usr/lib")
|
|
||||||
# $CFLAGS << " -I/usr/include"
|
|
||||||
test_func = "socket"
|
test_func = "socket"
|
||||||
# have_library("bind", "gethostbyaddr")
|
|
||||||
when /beos/
|
when /beos/
|
||||||
test_func = "socket"
|
test_func = "socket"
|
||||||
have_library("net", "socket")
|
have_library("net", "socket")
|
||||||
@ -86,19 +47,13 @@ $ipv6lib = nil
|
|||||||
$ipv6libdir = nil
|
$ipv6libdir = nil
|
||||||
$ipv6trylibc = nil
|
$ipv6trylibc = nil
|
||||||
if $ipv6
|
if $ipv6
|
||||||
if egrep_cpp("yes", <<EOF)
|
if macro_defined?("IPV6_INRIA_VERSION", <<EOF)
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#ifdef IPV6_INRIA_VERSION
|
|
||||||
yes
|
|
||||||
#endif
|
|
||||||
EOF
|
EOF
|
||||||
$ipv6type = "inria"
|
$ipv6type = "inria"
|
||||||
$CFLAGS="-DINET6 "+$CFLAGS
|
$CFLAGS="-DINET6 "+$CFLAGS
|
||||||
elsif egrep_cpp("yes", <<EOF)
|
elsif macro_defined?("__KAME__", <<EOF)
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#ifdef __KAME__
|
|
||||||
yes
|
|
||||||
#endif
|
|
||||||
EOF
|
EOF
|
||||||
$ipv6type = "kame"
|
$ipv6type = "kame"
|
||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
@ -110,31 +65,22 @@ EOF
|
|||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
$ipv6libdir="/usr/inet6/lib"
|
$ipv6libdir="/usr/inet6/lib"
|
||||||
$CFLAGS="-DINET6 -I/usr/inet6/include "+$CFLAGS
|
$CFLAGS="-DINET6 -I/usr/inet6/include "+$CFLAGS
|
||||||
elsif egrep_cpp("yes", <<EOF)
|
elsif macro_defined?("_TOSHIBA_INET6", <<EOF)
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#ifdef _TOSHIBA_INET6
|
|
||||||
yes
|
|
||||||
#endif
|
|
||||||
EOF
|
EOF
|
||||||
$ipv6type = "toshiba"
|
$ipv6type = "toshiba"
|
||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
$ipv6libdir="/usr/local/v6/lib"
|
$ipv6libdir="/usr/local/v6/lib"
|
||||||
$CFLAGS="-DINET6 "+$CFLAGS
|
$CFLAGS="-DINET6 "+$CFLAGS
|
||||||
elsif egrep_cpp("yes", <<EOF)
|
elsif macro_defined?("__V6D__", <<EOF)
|
||||||
#include </usr/local/v6/include/sys/v6config.h>
|
#include </usr/local/v6/include/sys/v6config.h>
|
||||||
#ifdef __V6D__
|
|
||||||
yes
|
|
||||||
#endif
|
|
||||||
EOF
|
EOF
|
||||||
$ipv6type = "v6d"
|
$ipv6type = "v6d"
|
||||||
$ipv6lib="v6"
|
$ipv6lib="v6"
|
||||||
$ipv6libdir="/usr/local/v6/lib"
|
$ipv6libdir="/usr/local/v6/lib"
|
||||||
$CFLAGS="-DINET6 -I/usr/local/v6/include "+$CFLAGS
|
$CFLAGS="-DINET6 -I/usr/local/v6/include "+$CFLAGS
|
||||||
elsif egrep_cpp("yes", <<EOF)
|
elsif macro_defined?("_ZETA_MINAMI_INET6", <<EOF)
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#ifdef _ZETA_MINAMI_INET6
|
|
||||||
yes
|
|
||||||
#endif
|
|
||||||
EOF
|
EOF
|
||||||
$ipv6type = "zeta"
|
$ipv6type = "zeta"
|
||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
|
50
lib/mkmf.rb
50
lib/mkmf.rb
@ -204,14 +204,6 @@ def try_compile(src, opt="")
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def macro_defined?(macro, src, opt="")
|
|
||||||
try_cpp(src + <<EOP, opt)
|
|
||||||
#ifndef #{macro}
|
|
||||||
# error
|
|
||||||
#endif
|
|
||||||
EOP
|
|
||||||
end
|
|
||||||
|
|
||||||
def try_cpp(src, opt="")
|
def try_cpp(src, opt="")
|
||||||
cfile = open("conftest.c", "w")
|
cfile = open("conftest.c", "w")
|
||||||
cfile.print src
|
cfile.print src
|
||||||
@ -252,6 +244,14 @@ def egrep_cpp(pat, src, opt="")
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def macro_defined?(macro, src, opt="")
|
||||||
|
try_cpp(src + <<EOP, opt)
|
||||||
|
#ifndef #{macro}
|
||||||
|
# error
|
||||||
|
#endif
|
||||||
|
EOP
|
||||||
|
end
|
||||||
|
|
||||||
def try_run(src, opt="")
|
def try_run(src, opt="")
|
||||||
begin
|
begin
|
||||||
if try_link0(src, opt)
|
if try_link0(src, opt)
|
||||||
@ -439,6 +439,40 @@ SRC
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def have_struct_member(type, member, header=nil)
|
||||||
|
message "checking for #{type}.#{member}... "
|
||||||
|
|
||||||
|
src =
|
||||||
|
if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM
|
||||||
|
r = <<"SRC"
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winsock.h>
|
||||||
|
SRC
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
unless header.nil?
|
||||||
|
header = [header] unless header.kind_of? Array
|
||||||
|
header.each {|h|
|
||||||
|
src << <<"SRC"
|
||||||
|
#include <#{h}>
|
||||||
|
SRC
|
||||||
|
}
|
||||||
|
end
|
||||||
|
src << <<"SRC"
|
||||||
|
int main() { return 0; }
|
||||||
|
int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
|
||||||
|
SRC
|
||||||
|
r = try_compile(src)
|
||||||
|
unless r
|
||||||
|
message "no\n"
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
$defs.push(format("-DHAVE_ST_%s", member.upcase))
|
||||||
|
message "yes\n"
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
def find_executable(bin, path = nil)
|
def find_executable(bin, path = nil)
|
||||||
message "checking for #{bin}... "
|
message "checking for #{bin}... "
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user