~ chicken-core (chicken-5) 50f521d1c81a143aebe4cd1a285af784dc475f4e


commit 50f521d1c81a143aebe4cd1a285af784dc475f4e
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Fri Jul 22 14:08:53 2011 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Fri Jul 22 14:08:53 2011 +0200

    tiredly pounding

diff --git a/build-version.scm b/build-version.scm
index f79b4385..1e895897 100644
--- a/build-version.scm
+++ b/build-version.scm
@@ -27,6 +27,8 @@
 (declare
  (unit build-version))
 
+(foreign-declare "#include \"buildtag.h\"")
+
 ;; (read-version filename): Read line from FILENAME and return
 ;; as a string; return #f if non-existent file or blank line.
 (define-syntax read-version
@@ -35,11 +37,11 @@
      (let ((fn (cadr x)))
        (and (file-exists? fn)
 	    (let ((ver (with-input-from-file (cadr x) read-line)))
-	      (if (string=? ver "")
+	      (if (or (eof-object? ver) (string=? ver ""))
 		  #f
 		  ver)))))))
 
-(define ##sys#build-version (read-version "buildversion"))
-(define ##sys#build-tag     (read-version "buildtag"))
+(define (##sys#build-tag)   (foreign-value "C_BUILD_TAG" c-string))
 (define ##sys#build-id      (read-version "buildid"))
 (define ##sys#build-branch  (read-version "buildbranch"))
+(define ##sys#build-version (read-version "buildversion"))
diff --git a/distribution/manifest b/distribution/manifest
index c10fd596..9e69eed3 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -45,6 +45,7 @@ tcp.c
 utils.c
 build.scm
 buildversion
+buildbranch
 c-backend.scm
 c-platform.scm
 chicken-ffi-syntax.scm
@@ -95,6 +96,9 @@ stub.scm
 support.scm
 tcp.scm
 build-version.scm
+build-version.c
+buildid
+buildtag.h
 tests/thread-list.scm
 tests/gobble.scm
 tests/test-optional.scm
diff --git a/identify.sh b/identify.sh
index cbf507b4..8ec08d5a 100644
--- a/identify.sh
+++ b/identify.sh
@@ -7,12 +7,12 @@
 
 # make sure file exists anyway, since branchname is a special case
 if test \! -e "buildbranch"; then
-    echo >buildbranch
+    touch buildbranch
 fi
 
 rev0=`cat buildid || echo ""`
 branchname0=`cat buildbranch || echo ""`
-tag0=`cat buildtag || echo ""`
+tag0=`cat buildtag.h || echo ""`
 buildtime=`date +%Y-%m-%d`
 host=`hostname`
 usys=`uname`
@@ -20,7 +20,7 @@ usys=`uname`
 if test -d "$1/.git"; then
     rev=`GIT_DIR="$1/.git" git rev-parse --short HEAD 2>/dev/null`
     branchname=`GIT_DIR="$1/.git" git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
-    tag="compiled ${buildtime} on ${host} (${usys})"
+    tag="#define C_BUILD_TAG \"compiled ${buildtime} on ${host} (${usys})\""
 
     case ${branchname} in
 	"") branchname="";;
@@ -33,6 +33,6 @@ if test -d "$1/.git"; then
 	echo ${branchname} >buildbranch
     fi
     if test "${tag0}" \!= "${tag}"; then
-	echo ${tag} >buildtag
+	echo ${tag} >buildtag.h
     fi
 fi
diff --git a/library.scm b/library.scm
index d9d9f86d..4b5ff135 100644
--- a/library.scm
+++ b/library.scm
@@ -3547,7 +3547,7 @@ EOF
 	     ""
 	     (string-append " [" spec " ]") )
 	 "\n"
-	 (or ##sys#build-tag "")))
+	 (or (##sys#build-tag) "")))
       ##sys#build-version) )
 
 
diff --git a/rules.make b/rules.make
index 614ca2b9..fc719023 100644
--- a/rules.make
+++ b/rules.make
@@ -464,10 +464,10 @@ endif
 # build versioning
 
 ifdef WINDOWS_SHELL
-.PHONY: buildtag buildbranch buildid
+.PHONY: buildbranch buildid
 
-buildtag:
-	echo.$(BUILD_TAG)>buildtag
+buildtag.h:
+	echo #define C_BUILD_TAG "$(BUILD_TAG)" >$@
 buildbranch:
 	echo.$(BRANCHNAME)>buildbranch
 buildid:
@@ -478,7 +478,7 @@ else
 identify-me:
 	@sh $(SRCDIR)identify.sh $(SRCDIR)
 
-buildtag: identify-me
+buildtag.h: identify-me
 buildbranch: identify-me
 buildid: identify-me
 endif
@@ -548,7 +548,8 @@ profiler.c: $(SRCDIR)profiler.scm $(SRCDIR)common-declarations.scm
 	$(bootstrap-lib) 
 stub.c: $(SRCDIR)stub.scm $(SRCDIR)common-declarations.scm
 	$(bootstrap-lib) 
-build-version.c: $(SRCDIR)build-version.scm buildtag buildbranch buildid $(SRCDIR)buildversion
+build-version.c: $(SRCDIR)build-version.scm buildbranch buildid \
+	  $(SRCDIR)buildversion buildtag.h
 	$(bootstrap-lib)
 
 define declare-bootstrap-import-lib
@@ -632,7 +633,7 @@ endif
 confclean:
 	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) \
 	  chicken-config.h chicken-defaults.h chicken-install.rc chicken-uninstall.rc \
-	  buildtag buildid buildbranch
+	  buildtag.h buildid buildbranch
 
 spotless: distclean testclean
 	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(DISTFILES)
Trap