Bug #8256
closeddependency to include/ruby/version.h
Description
気がついたのですが、in-place で ruby を build した場合に
include/ruby/version.h を更新して make しても version.o が更新されません。
以下では、include/ruby/version.h を更新して、
更新時刻が version.o よりも include/ruby/version.h のほうが新しくなっていますが、
make version.o としても、結局、
gmake: `version.o' is up to date.
といわれてしまって更新されません。(version.o の更新時刻が変わりません)
% echo '/**/' >> include/ruby/version.h
% ls -l version.o include/ruby/version.h
-rw-r--r-- 1 akr akr 1870 Apr 11 23:54 include/ruby/version.h
-rw-r--r-- 1 akr akr 206584 Apr 11 23:45 version.o
% make version.o
running CONFIG_SHELL=/bin/bash /bin/bash ./configure --prefix=/home/akr/ruby/tst6 CC=/home/src/gcc/bin/gcc --disable-install-doc --with-valgrind CPPFLAGS=-DRUBY_DEBUG_ENV optflags=-O0 debugflags=-save-temps=obj -g3 warnflags=-W -Wall -Wformat=2 -Wundef -Wno-parentheses -Wno-unused-parameter -Wno-missing-field-initializers --no-create --no-recursion
checking build system type... x86_64-unknown-linux-gnu
...
checking for nroff... /usr/bin/nroff
.ext/include/x86_64-linux/ruby/config.h unchanged
verconf.h unchanged
ruby library version = 2.1.0
configure: creating ./config.status
MAKE=gmake /bin/sh ./config.status
config.status: creating GNUmakefile
config.status: creating Makefile
config.status: creating ruby-2.1.pc
Makefile unchanged
MAKE=gmake /bin/sh ./config.status
config.status: creating GNUmakefile
config.status: creating Makefile
config.status: creating ruby-2.1.pc
Makefile unchanged
gmake: `version.o' is up to date.
% ls -l version.o include/ruby/version.h
-rw-r--r-- 1 akr akr 1870 Apr 11 23:54 include/ruby/version.h
-rw-r--r-- 1 akr akr 206584 Apr 11 23:45 version.o
gcc の -MM オプションで実際に include しているファイルを調べてみると、
以下のように include/ruby/version.h は含まれているので、version.o も
更新されるのが適切でしょう。
version.o: version.c verconf.h include/ruby/ruby.h
.ext/include/x86_64-linux/ruby/config.h include/ruby/defines.h
include/ruby/missing.h include/ruby/intern.h include/ruby/defines.h
include/ruby/st.h include/ruby/subst.h version.h include/ruby/version.h
revision.h
そして、common.mk には以下のように、include/ruby 下の version.h を示す、
{$(VPATH)}version.h がちゃんと書いてあります。
そして、ソースディレクトリ直下の version.h を示す $(srcdir)/version.h も書いてあります。
version.$(OBJEXT): {$(VPATH)}version.c $(RUBY_H_INCLUDES)
{$(VPATH)}version.h $(srcdir)/version.h $(srcdir)/revision.h {$(VPATH)}config.h
verconf.h
問題は、 version.h という名前のファイルが include/ruby だけでなく
ソースディレクトリ直下にもあることです。
gmake は VPATH に従ったディレクトリを探す前にカレントディレクトリを探すので
カレントディレクトリの version.h を見つけてそちらへの依存だと判断してしまいます。
これは make -p で make が読み取った依存関係を調べると確認できます。
% make -p |grep '^version.o'
...
version.o: version.c version.c ./include/ruby/ruby.h .ext/include/x86_64-linux/ruby/config.h ./include/ruby/defines.h ./include/ruby/intern.h ./include/ruby/missing.h ./include/ruby/st.h ./include/ruby/subst.h version.h version.h revision.h .ext/include/x86_64-linux/ruby/config.h verconf.h .ext/include/x86_64-linux/ruby/config.h ./include/ruby/missing.h
ここでは version.h がふたつあって、{$(VPATH)}version.h と $(srcdir)/version.h の両方が
version.h に展開されていることが分かります。
根本的には、version.h という同名のファイルがあるのが問題なので、
外部に公開されていないソースディレクトリ直下の version.h を rename すればいいんじゃないかと思うんですが
どうでしょうか。
で、新しい名前は verdata.h とかどうでしょう。
RUBY_VERSION とかの実際のデータが定義されているので。
なお、version.h は自動更新されるのでそちらの仕掛けも調整しないといけないと思います。
Updated by akr (Akira Tanaka) about 12 years ago
もうちょっと考えたら、common.mk で単に {$(VPATH)}version.h を
$(srcdir)/include/ruby/version.h に変えればいいような気がしてきました。
そうすべきでない理由はあるでしょうか?
Updated by akr (Akira Tanaka) about 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r40261.
Akira, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- common.mk: version.o depends on $(srcdir)/include/ruby/version.h
instead of {$(VPATH)}version.h to avoid confusion by VPATH between
top level version.h and include/ruby/version.h for build in-place.
[ruby-dev:47249] [Bug #8256]