From: Katsuyuki Komatsu Date: 1999-05-01T14:36:21+09:00 Subject: [ruby-dev:6700] [PATCH] Ruby 1.3.3-990430 小松です。 socketの所のinet_ntop()とinet_pton()の仕様がよく分からないので 推測で作ってますが、以下のパッチで、 Solaris 2.5.1, SunOS 4.1.4, HP-UX 10.20, AIX 4.1.3 でコンパイルできました。 動作確認まではしてませんが。 (1) mkconfig.rbが変更されて、rbconfig.rbが、 CONFIG["LIBRUBY_A"] = "lib$(RUBY_INSTALL_NAME).a" と生成されインストールに失敗するようになったため、 instruby.rbで$()を展開するようにした。 (2) instruby.rbでPLATFORMを/ibm-aix/と比較しているのを/-aix/に変更。 (3) 拡張ライブラリのOBJSにconftest.oが入ってしまう場合があるため extmk.rb.in, mkmf.rbで対策。 (4) mkmf.rbの$(TARGET)がベースネームになるように変更。 (5) kconv.cコンパイル時のwarningがいやだったのでconstを追加。 (6) HP-UX 10.20でext/curses/curses.cがコンパイルできなかったので、 varargs.hを追加。 (7) HP-UX 10.20でreadlineのリンクが失敗したため、 ext/readline/extconf.rbを変更。 (8) ext/socketが上記のプラットフォームでコンパイルできる通るように変更。 ただし、inet_ntop()とinet_pton()は仕様がよく分からないので推測。 関数の存在を、ext/socket/extconf.rbで、 have_func("inet_ntop") have_func("inet_pton") でチェックしただけでいいのかどうか不明。 addrinfo.hの__P()の定義とu_int8_tの対策が手抜き。 / / / Index: ruby/instruby.rb =================================================================== RCS file: /home/cvs/ruby/instruby.rb,v retrieving revision 1.1.1.2.2.10 diff -u -r1.1.1.2.2.10 instruby.rb --- instruby.rb 1999/04/26 09:42:31 1.1.1.2.2.10 +++ instruby.rb 1999/05/01 05:03:10 @@ -3,6 +3,13 @@ require "rbconfig.rb" include Config +def expand(arg) + arg.gsub!(/\$\(?([^()]+)\)?/) { + CONFIG[$1] + } + arg +end + destdir = ARGV[0] || '' $:.unshift CONFIG["srcdir"]+"/lib" @@ -31,18 +38,18 @@ File.install dll, "#{bindir}/#{dll}", 0755, true end File.makedirs libdir, true -for lib in ["libruby.so.LIB", CONFIG["LIBRUBY_SO"]] +for lib in ["libruby.so.LIB", expand(CONFIG["LIBRUBY_SO"])] if File.exist? lib File.install lib, libdir, 0644, true end end Dir.chdir libdir -if File.exist? CONFIG["LIBRUBY_SO"] - for link in CONFIG["LIBRUBY_ALIASES"].split +if File.exist? expand(CONFIG["LIBRUBY_SO"]) + for link in expand(CONFIG["LIBRUBY_ALIASES"]).split if File.exist? link File.delete link end - File.symlink CONFIG["LIBRUBY_SO"], link + File.symlink expand(CONFIG["LIBRUBY_SO"]), link print "link #{CONFIG['LIBRUBY_SO']} -> #{link}\n" end end @@ -60,13 +67,13 @@ File.install f, dir, 0644, true end -if PLATFORM =~ /ibm-aix/ +if PLATFORM =~ /-aix/ File.install "ruby.imp", archdir, 0644, true end for f in Dir["*.h"] File.install f, archdir, 0644, true end -File.install wdir+'/'+CONFIG['LIBRUBY_A'], archdir, 0644, true +File.install wdir+'/'+expand(CONFIG['LIBRUBY_A']), archdir, 0644, true File.makedirs mandir, true File.install "ruby.1", mandir, 0644, true Index: ruby/ext/extmk.rb.in =================================================================== RCS file: /home/cvs/ruby/ext/extmk.rb.in,v retrieving revision 1.1.1.3.2.16 diff -u -r1.1.1.3.2.16 extmk.rb.in --- extmk.rb.in 1999/04/30 08:20:49 1.1.1.3.2.16 +++ extmk.rb.in 1999/05/01 05:03:13 @@ -353,6 +353,7 @@ if !$objs then $objs = [] for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{c,cc}"] + next if f =~ '/conftest.c$' f = File.basename(f) f.sub!(/\.(c|cc)$/, ".o") $objs.push f Index: ruby/ext/curses/curses.c =================================================================== RCS file: /home/cvs/ruby/ext/curses/curses.c,v retrieving revision 1.1.1.3.2.2 diff -u -r1.1.1.3.2.2 curses.c --- curses.c 1999/02/25 06:39:12 1.1.1.3.2.2 +++ curses.c 1999/05/01 05:03:13 @@ -10,10 +10,11 @@ #else # ifdef HAVE_NCURSES_CURSES_H # include -# else -#ifdef __hpux -#include #else +# ifdef HAVE_CURSES_COLR_CURSES_H +# include +# include +# else # include # if (defined(__bsdi__) || defined(__NetBSD__)) && !defined(_maxx) # define _maxx maxx Index: ruby/ext/kconv/kconv.c =================================================================== RCS file: /home/cvs/ruby/ext/kconv/kconv.c,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 kconv.c --- kconv.c 1999/01/20 04:59:33 1.1.1.3 +++ kconv.c 1999/05/01 05:03:15 @@ -1780,7 +1780,7 @@ VALUE src, dst; VALUE in, out; int in_code, out_code; - char *codename = 0; + const char *codename = 0; rb_scan_args(argc, argv, "12", &src, &out, &in); Check_Type(src, T_STRING); Index: ruby/ext/readline/extconf.rb =================================================================== RCS file: /home/cvs/ruby/ext/readline/extconf.rb,v retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1.2.1 extconf.rb --- extconf.rb 1999/04/27 05:11:12 1.1.1.1.2.1 +++ extconf.rb 1999/05/01 05:03:15 @@ -17,6 +17,7 @@ end have_library("termcap", "tgetnum") +have_library("curses", "tgetnum") if have_header("readline/readline.h") and have_header("readline/history.h") and have_library("readline", "readline") Index: ruby/ext/socket/addrinfo.h =================================================================== RCS file: /home/cvs/ruby/ext/socket/Attic/addrinfo.h,v retrieving revision 1.1.2.3 diff -u -r1.1.2.3 addrinfo.h --- addrinfo.h 1999/04/30 15:16:44 1.1.2.3 +++ addrinfo.h 1999/05/01 05:03:15 @@ -65,6 +65,8 @@ #define freehostent freehostent__compat #define freeaddrinfo freeaddrinfo__compat +#define __P(args) args + /* special compatibility hack -- end*/ @@ -129,9 +131,9 @@ }; struct sockaddr_storage { - u_int8_t __ss_len; - u_int8_t __ss_family; - u_int8_t fill[126]; + unsigned char __ss_len; + unsigned char __ss_family; + unsigned char fill[126]; }; extern int getaddrinfo __P(( Index: ruby/ext/socket/extconf.rb =================================================================== RCS file: /home/cvs/ruby/ext/socket/extconf.rb,v retrieving revision 1.1.1.3.2.5 diff -u -r1.1.1.3.2.5 extconf.rb --- extconf.rb 1999/04/30 15:16:44 1.1.1.3.2.5 +++ extconf.rb 1999/05/01 05:03:16 @@ -149,6 +149,8 @@ $CFLAGS="-DHAVE_SA_LEN "+$CFLAGS end +have_header("sys/sysctl.h") + $getaddr_info_ok = false if try_run(< @@ -270,6 +272,8 @@ $CFLAGS="-I. "+$CFLAGS $objs += "getaddrinfo.o" $objs += "getnameinfo.o" + have_func("inet_ntop") + have_func("inet_pton") end if sockaddr_storage Index: ruby/ext/socket/getaddrinfo.c =================================================================== RCS file: /home/cvs/ruby/ext/socket/Attic/getaddrinfo.c,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 getaddrinfo.c --- getaddrinfo.c 1999/04/30 15:16:44 1.1.2.2 +++ getaddrinfo.c 1999/05/01 05:03:17 @@ -40,7 +40,9 @@ #include #include -#include +#if HAVE_SYS_SYSCTL_H +# include +#endif #include #include #include @@ -48,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -160,7 +163,7 @@ memcpy(ai, pai, sizeof(struct addrinfo));\ (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ memset((ai)->ai_addr, 0, (afd)->a_socklen);\ - SET_SA_LEN(*(ai)->ai_addr, (ai)->ai_addrlen = (afd)->a_socklen);\ + SET_SA_LEN((ai)->ai_addr, (ai)->ai_addrlen = (afd)->a_socklen);\ (ai)->ai_addr->sa_family = (ai)->ai_family = (afd)->a_af;\ ((struct sockinet *)(ai)->ai_addr)->si_port = port;\ p = (char *)((ai)->ai_addr);\ @@ -205,6 +208,27 @@ } return YES; } + +#ifndef HAVE_INET_PTON + +#ifndef INADDR_NONE +# define INADDR_NONE 0xffffffff +#endif + +static int +inet_pton(af, hostname, pton) + int af; + const char *hostname; + char *pton; +{ + struct in_addr in; + in.s_addr = inet_addr(hostname); + if (in.s_addr == INADDR_NONE) + return 0; + memcpy(pton, &in, sizeof(in)); + return 1; +} +#endif int getaddrinfo(hostname, servname, hints, res) Index: ruby/ext/socket/getnameinfo.c =================================================================== RCS file: /home/cvs/ruby/ext/socket/Attic/getnameinfo.c,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 getnameinfo.c --- getnameinfo.c 1999/04/30 15:16:44 1.1.2.2 +++ getnameinfo.c 1999/05/01 05:03:17 @@ -81,6 +81,21 @@ #define ENI_FAMILY 5 #define ENI_SALEN 6 +#ifndef HAVE_INET_NTOP +static char * +inet_ntop(af, addr, numaddr, numaddr_len) + int af; + char *addr; + char *numaddr; + int numaddr_len; +{ + struct in_addr in; + memcpy(&in.s_addr, addr, sizeof(in.s_addr)); + strcpy(numaddr, inet_ntoa(in)); + return numaddr; +} +#endif + int getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) const struct sockaddr *sa; @@ -102,6 +117,9 @@ int h_error; char numserv[512]; char numaddr[512]; +#ifndef INET6 + extern int h_errno; +#endif if (sa == NULL) return ENI_NOSOCKET; Index: ruby/ext/socket/sockport.h =================================================================== RCS file: /home/cvs/ruby/ext/socket/Attic/sockport.h,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 sockport.h --- sockport.h 1999/04/30 15:16:45 1.1.2.1 +++ sockport.h 1999/05/01 05:03:17 @@ -13,7 +13,7 @@ #ifndef SA_LEN # ifdef HAVE_SA_LEN -# define SA_LEN(sa) (sa)->sin_len +# define SA_LEN(sa) (sa)->sa_len # else # ifdef INET6 # define SA_LEN(sa) \ @@ -27,7 +27,7 @@ #endif #ifdef HAVE_SA_LEN -# define SET_SA_LEN(sa, len) (sa)->sin_len = (len) +# define SET_SA_LEN(sa, len) (sa)->sa_len = (len) #else # define SET_SA_LEN(sa, len) (len) #endif Index: ruby/lib/mkmf.rb =================================================================== RCS file: /home/cvs/ruby/lib/mkmf.rb,v retrieving revision 1.1.1.2.2.12 diff -u -r1.1.1.2.2.12 mkmf.rb --- mkmf.rb 1999/04/30 08:20:49 1.1.1.2.2.12 +++ mkmf.rb 1999/05/01 05:03:17 @@ -329,6 +329,7 @@ unless $objs then $objs = Dir["*.{c,cc}"] + $objs.delete("conftest.c") for f in $objs f.sub!(/\.(c|cc)$/, ".o") end @@ -363,14 +364,15 @@ LIBS = #{$libs} OBJS = #{$objs} -TARGET = #{target}.#{CONFIG["DLEXT"]} +TARGET = #{target} +DLLIB = $(TARGET).#{CONFIG["DLEXT"]} INSTALL = #{$install} INSTALL_DATA = #{$install_data} binsuffix = #{CONFIG["binsuffix"]} -all: $(TARGET) +all: $(DLLIB) clean:; @rm -f *.o *.so *.sl @rm -f Makefile extconf.h conftest.* @@ -378,30 +380,30 @@ realclean: clean -install: $(archdir)/$(TARGET) +install: $(archdir)/$(DLLIB) -$(archdir)/$(TARGET): $(TARGET) +$(archdir)/$(DLLIB): $(DLLIB) @test -d $(libdir) || mkdir $(libdir) @test -d $(archdir) || mkdir $(archdir) - $(INSTALL) $(TARGET) $(archdir)/$(TARGET) + $(INSTALL) $(DLLIB) $(archdir)/$(DLLIB) EOMF install_rb(mfile) mfile.printf "\n" if CONFIG["DLEXT"] != "o" mfile.printf <