[ruby-dev:28653] create header (Re: Re: ossl_cipher.c:124: warning: control reaches end of non-void function)
From:
"Nobuyoshi Nakada" <nobu@...>
Date:
2006-05-18 09:14:30 UTC
List:
ruby-dev #28653
なかだです。
06/05/11 に Tanaka Akira<akr@m17n.org> さんは書きました:
> うぅむ。行が切れてしまった。
>
> そういえば、この、コマンドライン引数に HAVE_XXX というマクロ
> をつける、というのはなんでなんでしょう?
それが、他のコードよりも必ず先に定義される一番確実な方法だからです。
常にファイルに保存するようにしたほうが、条件が変わったときに再コンパイルされてうれしいかもしれません。
* ruby.h, ext/extmk.rb, lib/mkmf.rb: always create extconf header, and
include.
* ext/readline/readline.c: include ruby.h before HAVE_* macros.
Index: ruby.h
===================================================================
RCS file: /pub/cvs/ruby/src/ruby/ruby.h,v
retrieving revision 1.134
diff -U 2 -p -r1.134 ruby.h
--- ruby.h 2 Mar 2006 05:22:30 -0000 1.134
+++ ruby.h 18 May 2006 01:32:25 -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: /pub/cvs/ruby/src/ruby/ext/extmk.rb,v
retrieving revision 1.88
diff -U 2 -p -r1.88 extmk.rb
--- ext/extmk.rb 17 May 2006 15:41:31 -0000 1.88
+++ ext/extmk.rb 18 May 2006 01:32:25 -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/readline/readline.c
===================================================================
RCS file: /pub/cvs/ruby/src/ruby/ext/readline/readline.c,v
retrieving revision 1.27
diff -U 2 -p -r1.27 readline.c
--- ext/readline/readline.c 24 Sep 2005 00:17:43 -0000 1.27
+++ ext/readline/readline.c 18 May 2006 01:32:25 -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: lib/mkmf.rb
===================================================================
RCS file: /pub/cvs/ruby/src/ruby/lib/mkmf.rb,v
retrieving revision 1.238
diff -U 2 -p -r1.238 mkmf.rb
--- lib/mkmf.rb 17 May 2006 15:41:32 -0000 1.238
+++ lib/mkmf.rb 18 May 2006 01:33:44 -0000
@@ -829,19 +829,24 @@ end
def create_header(header = "extconf.h")
message "creating %s\n", header
- if $defs.length > 0
- 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
- end
- hfile.print "#endif\n"
+ sym = header.tr("a-z./\055", "A-Z___")
+ 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, "r+") do |hfile|
+ unless hfile.read == hdr
+ hfile.rewind
+ hfile.truncate(0)
+ hfile.write(hdr)
end
end
+ $extconf_h = header
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,5 @@ LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS #$ARCH_FLAG
-CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")}
#{$CPPFLAGS}
+CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{extconf_h}#{$CPPFLAGS}
CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
DLDFLAGS = #$LDFLAGS #$DLDFLAGS #$ARCH_FLAG
@@ -1064,4 +1070,8 @@ def create_makefile(target, srcprefix =
end
+ unless $extconf_h
+ create_header
+ end
+
libpath = libpathflag(libpath)
@@ -1260,4 +1270,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,4 +1284,5 @@ 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
@@ -1390,5 +1402,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はできる。
中田 伸悦