Hi,

At Sun, 31 Aug 2003 15:18:06 +0900,
Kurt M. Dresner wrote:
> It turns out that the thing I sent before was from a Solaris 9 machine,
> but apparently I need to compile it on a Solaris 8 machine.  When I went
> to the Solaris 8 machine and looked in that header file, there wasn't
> even a projid_t in the file, which makes me think it was different
> headers.

Try -E option to check the pre-processed source.

> So how do I go about figuring out what headers I need for sys/socket.h?
> 
> Here are the #include's from the file...

What file?

> #include <sys/types.h>
> #include <sys/uio.h>
> #include <sys/feature_tests.h>

Since -DHAVE_SYS_UIO_H is already defined, sys/feature_tests.h
is also necessary?

Although I guess it's a bug of Solaris.


Index: ext/socket/extconf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/ext/socket/extconf.rb,v retrieving revision 1.30 diff -u -2 -p -r1.30 extconf.rb --- ext/socket/extconf.rb 30 Jul 2003 00:32:03 -0000 1.30 +++ ext/socket/extconf.rb 31 Aug 2003 14:50:37 -0000 @@ -28,5 +28,5 @@ $ipv6 = false default_ipv6 = /cygwin/ !~ RUBY_PLATFORM if enable_config("ipv6", default_ipv6) - if try_link(<<EOF) + if checking_for("ipv6") {try_link(<<EOF)} #include <sys/types.h> #include <sys/socket.h> @@ -46,12 +46,9 @@ $ipv6libdir = nil $ipv6trylibc = nil if $ipv6 - if macro_defined?("IPV6_INRIA_VERSION", <<EOF) -#include <netinet/in.h> -EOF + checking_for("ipv6 type") { + if macro_defined?("IPV6_INRIA_VERSION", "#include <netinet/in.h>") $ipv6type = "inria" $CFLAGS="-DINET6 "+$CFLAGS - elsif macro_defined?("__KAME__", <<EOF) -#include <netinet/in.h> -EOF + elsif macro_defined?("__KAME__", "#include <netinet/in.h>") $ipv6type = "kame" $ipv6lib="inet6" @@ -64,21 +61,15 @@ EOF $ipv6libdir="/usr/inet6/lib" $CFLAGS="-DINET6 -I/usr/inet6/include "+$CFLAGS - elsif macro_defined?("_TOSHIBA_INET6", <<EOF) -#include <sys/param.h> -EOF + elsif macro_defined?("_TOSHIBA_INET6", "#include <sys/param.h>") $ipv6type = "toshiba" $ipv6lib="inet6" $ipv6libdir="/usr/local/v6/lib" $CFLAGS="-DINET6 "+$CFLAGS - elsif macro_defined?("__V6D__", <<EOF) -#include </usr/local/v6/include/sys/v6config.h> -EOF + elsif macro_defined?("__V6D__", "#include </usr/local/v6/include/sys/v6config.h>") $ipv6type = "v6d" $ipv6lib="v6" $ipv6libdir="/usr/local/v6/lib" $CFLAGS="-DINET6 -I/usr/local/v6/include "+$CFLAGS - elsif macro_defined?("_ZETA_MINAMI_INET6", <<EOF) -#include <sys/param.h> -EOF + elsif macro_defined?("_ZETA_MINAMI_INET6", "#include <sys/param.h>") $ipv6type = "zeta" $ipv6lib="inet6" @@ -90,5 +81,6 @@ EOF $CFLAGS="-DINET6 "+$CFLAGS end - + $ipv6type} + if $ipv6lib if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a" @@ -106,88 +98,32 @@ EOS end - if try_link(<<EOF) -#ifdef _WIN32 -# include <windows.h> -# include <winsock.h> -#else -# include <sys/types.h> -# include <netdb.h> -# include <string.h> -# include <sys/socket.h> -# include <netinet/in.h> -#endif -int -main() -{ - struct sockaddr_in sin; - - sin.sin_len; - return 0; -} -EOF - $CFLAGS="-DHAVE_SIN_LEN "+$CFLAGS +unless $mswin or $bccwin or $mingw + headers = %w<sys/types.h netdb.h string.h sys/socket.h netinet/in.h> +end +if /solaris/ =~ RUBY_PLATFORM and !try_compile("") + # bug of gcc 3.0 on Solaris 8 + headers << "sys/feature_tests.h" end - if try_link(<<EOF) -#ifdef _WIN32 -# include <windows.h> -# include <winsock.h> -#else -# include <sys/types.h> -# include <netdb.h> -# include <string.h> -# include <sys/socket.h> -#endif -int -main() -{ - struct sockaddr_storage ss; - - ss.ss_family; - return 0; -} -EOF - $CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS -else # doug's fix, NOW add -Dss_family... only if required! -$CPPFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len" - if try_link(<<EOF) -#ifdef _WIN32 -# include <windows.h> -# include <winsock.h> -#else -# include <sys/types.h> -# include <netdb.h> -# include <string.h> -# include <sys/socket.h> -#endif -int -main() -{ - struct sockaddr_storage ss; - - ss.ss_family; - return 0; -} -EOF - $CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS +if have_struct_member("struct sockaddr_in", "sin_len", headers) + $defs[-1] = "-DHAVE_SIN_LEN" end + +flags = " -Dss_family=__ss_family -Dss_len=__ss_len" +begin + if have_struct_member("struct sockaddr_storage", "ss_family", headers) + $defs[-1] = "-DHAVE_SOCKADDR_STORAGE" + elsif flags # doug's fix, NOW add -Dss_family... only if required! + $CPPFLAGS += flags + retry + end end - if try_link(<<EOF) -#include <sys/types.h> -#include <netdb.h> -#include <string.h> -#include <sys/socket.h> -#include <netinet/in.h> -int -main() -{ - struct sockaddr sa; +if have_struct_member("struct sockaddr", "sa_len", headers) + $defs[-1] = "-DHAVE_SA_LEN "+$CFLAGS +end - sa.sa_len; - return 0; -} -EOF - $CFLAGS="-DHAVE_SA_LEN "+$CFLAGS +unless have_type("socklen_t", headers) + $defs[-1] = "-Dsocklen_t=int" end @@ -201,10 +137,6 @@ end $getaddr_info_ok = false -if !enable_config("wide-getaddrinfo", false) and try_run(<<EOF) -#include <sys/types.h> -#include <netdb.h> -#include <string.h> -#include <sys/socket.h> -#include <netinet/in.h> +if !enable_config("wide-getaddrinfo", false) and checking_for("getaddrinfo") {try_run(<<EOF)} +#{cpp_include(headers)} #ifndef AF_LOCAL @@ -336,20 +268,4 @@ else have_header("arpa/nameser.h") have_header("resolv.h") -end - -if !try_link(<<EOF) -#include <sys/types.h> -#include <netdb.h> -#include <string.h> -#include <sys/socket.h> -#include <netinet/in.h> -int -main() -{ - socklen_t len; - return 0; -} -EOF - $CFLAGS="-Dsocklen_t=int "+$CFLAGS end
-- Nobu Nakada