summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-16 03:30:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-16 03:30:01 +0000
commit2bb561ea5f96f8b6edd622be16be89ee6af3cd7e (patch)
tree28a8858a3698a70a24b559fc46b52bb1d212f440
parent40819d4599203e324cab5c6beea33cfb09a6ddfc (diff)
* common.mk (REVISION_H): keeps timestamp of revision.h.
[ruby-core:22900] * tool/ifchange, win32/ifchange.bat: extended --timestamp option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--common.mk13
-rwxr-xr-xtool/ifchange36
-rwxr-xr-xwin32/ifchange.bat22
4 files changed, 61 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 7555e8551b..cc0a52c448 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Mar 16 12:30:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * common.mk (REVISION_H): keeps timestamp of revision.h.
+ [ruby-core:22900]
+
+ * tool/ifchange, win32/ifchange.bat: extended --timestamp option.
+
Mon Mar 16 09:28:58 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in, common.mk, win32/Makefile.sub: added preprocessing rules.
diff --git a/common.mk b/common.mk
index bb80ca1e58..3aea9e1ab2 100644
--- a/common.mk
+++ b/common.mk
@@ -16,6 +16,7 @@ STATIC_RUBY = static-ruby
EXTCONF = extconf.rb
RBCONFIG = ./.rbconfig.time
LIBRUBY_EXTS = ./.libruby-with-ext.time
+REVISION_H = ./.revision.time
RDOCOUT = $(EXTOUT)/rdoc
ID_H_TARGET = -id.h-
@@ -657,7 +658,8 @@ srcs-ext: $(EXT_SRCS)
srcs-enc: $(ENC_MK)
$(MAKE) -f $(ENC_MK) RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(MFLAGS) srcs
-incs: $(INSNS) {$(VPATH)}node_name.inc {$(VPATH)}encdb.h {$(VPATH)}transdb.h {$(VPATH)}known_errors.inc $(srcdir)/revision.h
+incs: $(INSNS) {$(VPATH)}node_name.inc {$(VPATH)}encdb.h {$(VPATH)}transdb.h {$(VPATH)}known_errors.inc \
+ $(srcdir)/revision.h $(REVISION_H)
insns: $(INSNS)
@@ -687,9 +689,12 @@ prereq: incs srcs preludes
preludes: {$(VPATH)}miniprelude.c
preludes: {$(srcdir)}golf_prelude.c
-$(srcdir)/revision.h: $(srcdir)/version.h $(srcdir)/ChangeLog $(srcdir)/tool/file2lastrev.rb $(REVISION_FORCE)
- @-$(BASERUBY) $(srcdir)/tool/file2lastrev.rb --revision.h "$(@D)" > "$@.tmp"
- @$(IFCHANGE) "$@" "$@.tmp"
+$(srcdir)/revision.h:
+ @exit > $@
+
+$(REVISION_H): $(srcdir)/version.h $(srcdir)/ChangeLog $(srcdir)/tool/file2lastrev.rb $(REVISION_FORCE)
+ @-$(BASERUBY) $(srcdir)/tool/file2lastrev.rb --revision.h "$(srcdir)" > "$(srcdir)/revision.tmp"
+ @$(IFCHANGE) "--timestamp=$@" "$(srcdir)/revision.h" "$(srcdir)/revision.tmp"
$(EXT_SRCS):
$(CHDIR) $(@D) && $(exec) $(MAKE) -f depend $(MFLAGS) top_srcdir=../.. srcdir=.
diff --git a/tool/ifchange b/tool/ifchange
index 8bfca26703..ca2ea40644 100755
--- a/tool/ifchange
+++ b/tool/ifchange
@@ -1,11 +1,22 @@
#!/bin/sh
# usage: ifchange target temporary
-unset timestamp
-if [ "$1" = --timestamp ]; then
- timestamp=yes
+timestamp=
+until [ "$0" = 0 ]; do
+ case "$1" in
+ --timestamp)
+ timestamp=.
+ ;;
+ --timestamp=*)
+ timestamp="${1#*=}" || timestamp=`expr "$1" : '[^=]*=\(.*\)'`
+ ;;
+ *)
+ break
+ ;;
+ esac
shift
-fi
+done
+
target="$1"
temp="$2"
if [ "$temp" = - ]; then
@@ -13,6 +24,7 @@ if [ "$temp" = - ]; then
cat > "$temp" || exit $?
trap 'rm -f "$temp"' 0
fi
+
if cmp "$target" "$temp" >/dev/null 2>&1; then
echo "$target unchanged"
rm -f "$temp"
@@ -20,6 +32,18 @@ else
echo "$target updated"
mv -f "$temp" "$target"
fi
-if [ $timestamp ]; then
- touch `dirname "$target"`/.time.`basename "$target"`
+
+if [ -n "${timestamp}" ]; then
+ if [ x"${timestamp}" = x. ]; then
+ case "$target" in
+ */*)
+ timestamp="${target%/*}"/.time."${target##*/}" ||
+ timestamp=`dirname "$target"`/.time.`basename "$target"`
+ ;;
+ *)
+ timestamp=.time."$target"
+ ;;
+ esac
+ fi
+ : > "$timestamp"
fi
diff --git a/win32/ifchange.bat b/win32/ifchange.bat
index 9f6092747b..24e4987c55 100755
--- a/win32/ifchange.bat
+++ b/win32/ifchange.bat
@@ -1,13 +1,20 @@
@echo off
:: usage: ifchange target temporary
-if "%1" == "" goto :end
-
set timestamp=
-if "%1" == "--timestamp" (
- set timestamp=yes
+:optloop
+for %%I in (%1) do set opt=%%~I
+if "%opt%" == "--timestamp" (
+ set timestamp=.
+ shift
+ goto :optloop
+) else if "%opt:~0,12%" == "--timestamp=" (
+ set timestamp=%opt:~12%
shift
+ goto :optloop
)
+if "%opt%" == "" goto :end
+
set dest=%1
set src=%2
set dest=%dest:/=\%
@@ -63,7 +70,8 @@ del %src%
:nt_end
if "%timestamp%" == "" goto :end
- for %%I in ("%dest%") do set timestamp=%%~dpI\.time.%%~nxI
- if not exist "%timestamp%" copy nul "%timestamp%" > nul
- goto :end >> "%timestamp%"
+ if "%timestamp%" == "." (
+ for %%I in ("%dest%") do set timestamp=%%~dpI.time.%%~nxI
+ )
+ goto :end > "%timestamp%"
:end