[ruby-dev:28660] Re: create header (Re: Re: ossl_cipher.c:124: warning: control reaches end of non-void function)
From:
nobu@...
Date:
2006-05-21 08:30:12 UTC
List:
ruby-dev #28660
なかだです。
At Sun, 21 May 2006 01:52:01 +0900,
Tanaka Akira wrote in [ruby-dev:28659]:
> どうやら、
>
> gcc -fPIC -g -O2 -DHAVE_CONFIG_H -I../../.././ext/digest/md5/.. -I. -I../../.. -I../../../. -I../../.././ext/digest/md5 -DRUBY_EXTCONF_H=\"extconf.h\" -c md5init.c
> gcc -fPIC -g -O2 -DHAVE_CONFIG_H -I../../.././ext/digest/md5/.. -I. -I../../.. -I../../../. -I../../.././ext/digest/md5 -DRUBY_EXTCONF_H=\"extconf.h\" -c md5ossl.c
>
> というようコンパイルして、openssl を使おうと判断して md5ossl.c
> を使ったが、md5init.c をコンパイルした時に
> -I../../.././ext/digest/md5/.. が -I. より先にあるので
> digest/md5/extconf.h でなく digest/extconf.h を読んだあげく
> にそこには HAVE_OPENSSL_MD5_H がないので問題が起こる、という
> ことのようです。うぅむ。
手元では再現しないと思ったら、ソースとは別のディレクトリでコン
パイルしているため、ext/digestのソースディレクトリにはextconf.h
が作られないからでした。
作り直したパッチです。
Index: ruby.h
===================================================================
RCS file: /cvs/ruby/src/ruby/ruby.h,v
retrieving revision 1.134
diff -p -U2 -r1.134 ruby.h
--- ruby.h 2 Mar 2006 05:22:30 -0000 1.134
+++ ruby.h 11 May 2006 14:46:59 -0000
@@ -23,4 +23,7 @@ extern "C" {
#include "config.h"
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
#define NORETURN_STYLE_NEW 1
Index: ext/extmk.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/extmk.rb,v
retrieving revision 1.88
diff -p -U2 -r1.88 extmk.rb
--- ext/extmk.rb 17 May 2006 15:41:31 -0000 1.88
+++ ext/extmk.rb 19 May 2006 15:39:06 -0000
@@ -125,4 +125,5 @@ def extmake(target)
begin
if (!(ok &&= extract_makefile(makefile)) ||
+ !$extconf_h || !File.exist?($extconf_h) ||
!(t = modified?(makefile, MTIMES)) ||
%W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend".any? {|f| modified?(f, [t])})
Index: ext/dbm/extconf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/dbm/extconf.rb,v
retrieving revision 1.16
diff -p -U2 -r1.16 extconf.rb
--- ext/dbm/extconf.rb 24 Jul 2003 07:41:36 -0000 1.16
+++ ext/dbm/extconf.rb 21 May 2006 00:54:24 -0000
@@ -34,5 +34,5 @@ def db_check(db)
for hdr in $dbm_conf_headers.fetch(db, ["ndbm.h"])
if have_header(hdr.dup) and have_type("DBM", hdr.dup, hsearch)
- $CFLAGS += " " + hsearch + '-DDBM_HDR="<'+hdr+'>"'
+ $defs << hsearch << '-DDBM_HDR="<'+hdr+'>"'
return true
end
Index: ext/digest/md5/extconf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/digest/md5/extconf.rb,v
retrieving revision 1.6
diff -p -U2 -r1.6 extconf.rb
--- ext/digest/md5/extconf.rb 21 Jan 2004 09:05:25 -0000 1.6
+++ ext/digest/md5/extconf.rb 21 May 2006 00:41:53 -0000
@@ -4,5 +4,6 @@
require "mkmf"
-$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
$objs = [ "md5init.#{$OBJEXT}" ]
Index: ext/digest/rmd160/extconf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/digest/rmd160/extconf.rb,v
retrieving revision 1.6
diff -p -U2 -r1.6 extconf.rb
--- ext/digest/rmd160/extconf.rb 21 Jan 2004 07:01:31 -0000 1.6
+++ ext/digest/rmd160/extconf.rb 21 May 2006 00:42:20 -0000
@@ -4,5 +4,6 @@
require "mkmf"
-$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+$defs << "-DNDEBUG" << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
$objs = [ "rmd160init.#{$OBJEXT}" ]
Index: ext/digest/sha1/extconf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/digest/sha1/extconf.rb,v
retrieving revision 1.6
diff -p -U2 -r1.6 extconf.rb
--- ext/digest/sha1/extconf.rb 7 Jan 2004 22:06:38 -0000 1.6
+++ ext/digest/sha1/extconf.rb 21 May 2006 00:42:46 -0000
@@ -4,5 +4,6 @@
require "mkmf"
-$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
$objs = [ "sha1init.#{$OBJEXT}" ]
Index: ext/digest/sha2/extconf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/digest/sha2/extconf.rb,v
retrieving revision 1.10
diff -p -U2 -r1.10 extconf.rb
--- ext/digest/sha2/extconf.rb 6 Sep 2005 23:22:39 -0000 1.10
+++ ext/digest/sha2/extconf.rb 21 May 2006 00:42:59 -0000
@@ -4,5 +4,6 @@
require "mkmf"
-$CPPFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
$objs = [
Index: ext/readline/readline.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/readline/readline.c,v
retrieving revision 1.27
diff -p -U2 -r1.27 readline.c
--- ext/readline/readline.c 24 Sep 2005 00:17:43 -0000 1.27
+++ ext/readline/readline.c 13 May 2006 13:09:08 -0000
@@ -2,4 +2,6 @@
Copyright (C) 1997-2001 Shugo Maeda */
+#include "ruby.h"
+
#include <errno.h>
#include <stdio.h>
@@ -16,5 +18,4 @@
#endif
-#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
Index: ext/socket/extconf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/socket/extconf.rb,v
retrieving revision 1.45
diff -p -U2 -r1.45 extconf.rb
--- ext/socket/extconf.rb 21 Oct 2005 06:46:41 -0000 1.45
+++ ext/socket/extconf.rb 21 Oct 2005 15:43:45 -0000
@@ -27,5 +27,5 @@ if /solaris/ =~ RUBY_PLATFORM and !try_c
end
-$ipv6 = false
+ipv6 = false
default_ipv6 = /cygwin/ !~ RUBY_PLATFORM
if enable_config("ipv6", default_ipv6)
@@ -38,61 +38,43 @@ main()
}
EOF
- $CPPFLAGS+=" -DENABLE_IPV6"
- $ipv6 = true
+ $defs << "-DENABLE_IPV6" << "-DINET6"
+ ipv6 = true
end
end
-$ipv6type = nil
-$ipv6lib = nil
-$ipv6libdir = nil
-$ipv6trylibc = nil
-if $ipv6
- if have_macro("IPV6_INRIA_VERSION", "netinet/in.h")
- $ipv6type = "inria"
- $CPPFLAGS="-DINET6 "+$CPPFLAGS
- elsif have_macro("__KAME__", "netinet/in.h")
- $ipv6type = "kame"
- $ipv6lib="inet6"
- $ipv6libdir="/usr/local/v6/lib"
- $ipv6trylibc=true
- $CPPFLAGS="-DINET6 "+$CPPFLAGS
- elsif File.directory? "/usr/inet6"
- $ipv6type = "linux"
- $ipv6lib="inet6"
- $ipv6libdir="/usr/inet6/lib"
- $CPPFLAGS="-DINET6 -I/usr/inet6/include "+$CPPFLAGS
- elsif have_macro("_TOSHIBA_INET6", "sys/param.h")
- $ipv6type = "toshiba"
- $ipv6lib="inet6"
- $ipv6libdir="/usr/local/v6/lib"
- $CPPFLAGS="-DINET6 "+$CPPFLAGS
- elsif have_macro("__V6D__", "/usr/local/v6/include/sys/v6config.h")
- $ipv6type = "v6d"
- $ipv6lib="v6"
- $ipv6libdir="/usr/local/v6/lib"
- $CFLAGS="-I/usr/local/v6/include "+$CFLAGS
- $CPPFLAGS="-DINET6 "+$CPPFLAGS
- elsif have_macro("_ZETA_MINAMI_INET6", "sys/param.h")
- $ipv6type = "zeta"
- $ipv6lib="inet6"
- $ipv6libdir="/usr/local/v6/lib"
- $CPPFLAGS="-DINET6 "+$CPPFLAGS
- else
- $ipv6lib=with_config("ipv6-lib", nil)
- $ipv6libdir=with_config("ipv6-libdir", nil)
- $CPPFLAGS="-DINET6 "+$CPPFLAGS
- end
-
- if $ipv6lib
- if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a"
- $LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib"
- elsif !$ipv6trylibc
- abort <<EOS
-Fatal: no #$ipv6lib library found. cannot continue.
-You need to fetch lib#{$ipv6lib}.a from appropriate
-ipv6 kit and compile beforehand.
+if ipv6
+ ipv6lib = nil
+ class << (fmt = "unknown")
+ def %(s) s || self end
+ end
+ idirs, ldirs = dir_config("inet6", %w[/usr/inet6 /usr/local/v6].find {|d| File.directory?(d)})
+ checking_for("ipv6 type", fmt) do
+ if have_macro("IPV6_INRIA_VERSION", "netinet/in.h")
+ "inria"
+ elsif have_macro("__KAME__", "netinet/in.h")
+ have_library(ipv6lib = "inet6")
+ "kame"
+ elsif have_macro("_TOSHIBA_INET6", "sys/param.h")
+ have_library(ipv6lib = "inet6") and "toshiba"
+ elsif have_macro("__V6D__", "sys/v6config.h")
+ have_library(ipv6lib = "v6") and "v6d"
+ elsif have_macro("_ZETA_MINAMI_INET6", "sys/param.h")
+ have_library(ipv6lib = "inet6") and "zeta"
+ elsif ipv6lib = with_config("ipv6-lib")
+ warn <<EOS
+--with-ipv6-lib and --with-ipv6-libdir option will be obsolete, use
+--with-inet6lib and --with-inet6-{include,lib} options instead.
EOS
+ find_library(ipv6lib, nil, with_config("ipv6-libdir", ldirs)) and
+ ipv6lib
+ elsif have_library("inet6")
+ "inet6"
end
- end
+ end or not ipv6lib or abort <<EOS
+
+Fatal: no #{ipv6lib} library found. cannot continue.
+You need to fetch lib#{ipv6lib}.a from appropriate
+ipv6 kit and compile beforehand.
+EOS
end
@@ -220,5 +202,5 @@ main()
EOF
end
-if $ipv6 and not getaddr_info_ok
+if ipv6 and not getaddr_info_ok
abort <<EOS
Index: ext/socket/socket.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/socket/socket.c,v
retrieving revision 1.159
diff -p -U2 -r1.159 socket.c
--- ext/socket/socket.c 3 Feb 2006 09:15:38 -0000 1.159
+++ ext/socket/socket.c 13 Feb 2006 23:58:39 -0000
@@ -2097,5 +2097,5 @@ sock_s_socketpair(klass, domain, type, p
VALUE klass, domain, type, protocol;
{
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__EMX__) && !defined(__QNXNTO__)
+#if defined HAVE_SOCKETPAIR
int d, t, sp[2];
Index: ext/zlib/extconf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/zlib/extconf.rb,v
retrieving revision 1.3
diff -p -U2 -r1.3 extconf.rb
--- ext/zlib/extconf.rb 9 Jan 2006 11:00:40 -0000 1.3
+++ ext/zlib/extconf.rb 21 May 2006 00:13:07 -0000
@@ -55,10 +55,5 @@ if %w'z libz zlib zdll'.find {|z| have_l
defines << "OS_CODE=#{os_code}"
- defines = defines.collect{|d|' -D'+d}.join
- if $CPPFLAGS then
- $CPPFLAGS += defines
- else
- $CFLAGS += defines
- end
+ $defs.concat(defines.collect{|d|' -D'+d})
create_makefile('zlib')
Index: lib/mkmf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/lib/mkmf.rb,v
retrieving revision 1.238
diff -p -U2 -r1.238 mkmf.rb
--- lib/mkmf.rb 17 May 2006 15:41:32 -0000 1.238
+++ lib/mkmf.rb 21 May 2006 00:40:13 -0000
@@ -274,13 +274,11 @@ end
def cc_command(opt="")
- RbConfig::expand("$(CC) -c #$INCFLAGS -I$(hdrdir) " \
- "#$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} #{CONFTEST_C}",
- CONFIG.merge('hdrdir' => $hdrdir.quote))
+ RbConfig::expand("$(CC) -c #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} #{CONFTEST_C}",
+ CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote))
end
def cpp_command(outfile, opt="")
- RbConfig::expand("$(CPP) #$INCFLAGS -I$(hdrdir) " \
- "#$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
- CONFIG.merge('hdrdir' => $hdrdir.quote))
+ RbConfig::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
+ CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote))
end
@@ -829,18 +827,25 @@ end
def create_header(header = "extconf.h")
message "creating %s\n", header
- if $defs.length > 0
+ unless $defs.empty?
sym = header.tr("a-z./\055", "A-Z___")
- open(header, "w") do |hfile|
- hfile.print "#ifndef #{sym}\n#define #{sym}\n"
- for line in $defs
- case line
- when /^-D([^=]+)(?:=(.*))?/
- hfile.print "#define #$1 #{$2 || 1}\n"
- when /^-U(.*)/
- hfile.print "#undef #$1\n"
- end
+ hdr = ["#ifndef #{sym}\n#define #{sym}\n"]
+ for line in $defs
+ case line
+ when /^-D([^=]+)(?:=(.*))?/
+ hdr << "#define #$1 #{$2 ? Shellwords.shellwords($2)[0] : 1}\n"
+ when /^-U(.*)/
+ hdr << "#undef #$1\n"
+ end
+ end
+ hdr << "#endif\n"
+ hdr = hdr.join
+ open(header, "w+") do |hfile|
+ unless hfile.read == hdr
+ hfile.rewind
+ hfile.truncate(0)
+ hfile.write(hdr)
end
- hfile.print "#endif\n"
end
+ $extconf_h = header
end
end
@@ -952,4 +957,5 @@ VPATH = #{vpath.join(CONFIG['PATH_SEPARA
sep = ""
end
+ extconf_h = $extconf_h ? "-DRUBY_EXTCONF_H=\\\"#{$extconf_h}\\\" " : ""
mk << %{
CC = #{CONFIG['CC']}
@@ -961,5 +967,6 @@ LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS #$ARCH_FLAG
-CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS}
+INCFLAGS = -I. #$INCFLAGS
+CPPFLAGS = #{extconf_h}#{$CPPFLAGS}
CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
DLDFLAGS = #$LDFLAGS #$DLDFLAGS #$ARCH_FLAG
@@ -1064,4 +1071,8 @@ def create_makefile(target, srcprefix =
end
+ unless $extconf_h
+ create_header
+ end
+
libpath = libpathflag(libpath)
@@ -1260,4 +1271,5 @@ site-install-rb: install-rb
end
headers << $config_h if $config_h
+ headers << $extconf_h if $extconf_h
mfile.print "$(OBJS): ", headers.join(' '), "\n"
end
@@ -1273,9 +1285,10 @@ def init_mkmf(config = CONFIG)
$enable_shared = config['ENABLE_SHARED'] == 'yes'
$defs = []
+ $extconf_h = nil
$CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
$ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup
$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup
$LDFLAGS = (with_config("ldflags") || "").dup
- $INCFLAGS = "-I$(topdir)"
+ $INCFLAGS = "-I$(topdir) -I$(hdrdir) -I$(srcdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
$LIBEXT = config['LIBEXT'].dup
@@ -1368,8 +1381,8 @@ COMMON_LIBS = config_string('COMMON_LIBS
COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
RULE_SUBST = config_string('RULE_SUBST')
-COMPILE_C = config_string('COMPILE_C') || '$(CC) $(CFLAGS) $(CPPFLAGS) -c $<'
-COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<'
+COMPILE_C = config_string('COMPILE_C') || '$(CC) -c $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $<'
+COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) -c $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $<'
TRY_LINK = config_string('TRY_LINK') ||
- "$(CC) #{OUTFLAG}conftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) " \
+ "$(CC) #{OUTFLAG}conftest $(INCFLAGS) $(CPPFLAGS) " \
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
LINK_SO = config_string('LINK_SO') ||
@@ -1390,5 +1403,5 @@ clean:
distclean: clean
- @-$(RM) Makefile extconf.h conftest.* mkmf.log
+ @-$(RM) Makefile #{$extconf_h} conftest.* mkmf.log
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep})
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦