diff --git a/LOG b/LOG
index 73c3349d87..24107c1467 100644
--- a/LOG
+++ b/LOG
@@ -1247,3 +1247,7 @@
newrelease pkg/Makefile release_notes.stex
- update Windows spin-loop count for deleting files and directories
windows.c
+- install a file containing revision information alongside boot files;
+ embed git revision in exported source archives
+ bintar/Makefile Mf-install.in wininstall/*nt.wxs
+ s/Mf-base s/.gitattributes s/update-revision
diff --git a/bintar/Makefile b/bintar/Makefile
index e88788fb32..046ab70c10 100644
--- a/bintar/Makefile
+++ b/bintar/Makefile
@@ -58,7 +58,7 @@ $(R)/examples: $(R)
$(R)/boot: $(R)
mkdir -p $(R)/boot/$(m)
- ( cd $(R)/boot/$(m) ; ln -s ../../../../boot/$(m)/{scheme.h,petite.boot,scheme.boot} . )
+ ( cd $(R)/boot/$(m) ; ln -s ../../../../boot/$(m)/{scheme.h,petite.boot,scheme.boot,revision} . )
case $(m) in \
*nt) \
( cd $R/boot/$(m) ; ln -s ../../../../boot/$(m)/{csv953md.lib,csv953mt.lib,mainmd.obj,mainmt.obj,scheme.res} . ) \
diff --git a/makefiles/Mf-install.in b/makefiles/Mf-install.in
index 0e1f51838c..a175284da3 100644
--- a/makefiles/Mf-install.in
+++ b/makefiles/Mf-install.in
@@ -59,6 +59,7 @@ Version=csv9.5.3
Include=boot/$m
PetiteBoot=boot/$m/petite.boot
SchemeBoot=boot/$m/scheme.boot
+Revision=boot/$m/revision
Scheme=bin/$m/scheme
Petite=bin/$m/petite
InstallLibExamples=${InstallLib}/${Version}/examples
@@ -118,6 +119,7 @@ libbininstall: ${LibBin}
$I -m 444 ${Include}/kernel.o ${LibBin}
$I -m 444 ${Include}/main.o ${LibBin}
$I -m 444 ${Include}/scheme.h ${LibBin}
+ $I -m 444 ${Revision} ${LibBin}/revision
maninstall: scheme.1 petite.1 ${Man}
$I -m 444 scheme.1 ${Man}/${InstallSchemeName}.1
diff --git a/s/.gitattributes b/s/.gitattributes
new file mode 100644
index 0000000000..25bdb21245
--- /dev/null
+++ b/s/.gitattributes
@@ -0,0 +1 @@
+update-revision export-subst
diff --git a/s/Mf-base b/s/Mf-base
index 11a2a32de3..4c6a101fb4 100644
--- a/s/Mf-base
+++ b/s/Mf-base
@@ -97,6 +97,7 @@ PetiteBoot = ../boot/$m/petite.boot
SchemeBoot = ../boot/$m/scheme.boot
Cheader = ../boot/$m/scheme.h
Cequates = ../boot/$m/equates.h
+Revision = ../boot/$m/revision
# The following controls the patch files loaded before compiling, typically used only
# to load a new compiler for cross compilation
@@ -152,11 +153,11 @@ allsrc =\
np-languages.ss
# doit uses a different Scheme process to compile each target
-doit: ${PetiteBoot} ${SchemeBoot} ${Cheader} ${Cequates}
+doit: ${PetiteBoot} ${SchemeBoot} ${Cheader} ${Cequates} ${Revision}
# all uses a single Scheme process to compile all targets. this is typically
# faster when most of the targets need to be recompiled.
-all: bootall ${Cheader} ${Cequates}
+all: bootall ${Cheader} ${Cequates} ${Revision}
# allx runs all up to three times and checks to see if the new boot file is the
# same as the last, i.e., the system is properly bootstrapped.
@@ -177,7 +178,7 @@ ifneq ($(OS),Windows_NT)
endif
# bootstrap runs allx if any sources have changed since the last bootstrap
-bootstrap: ${allsrc}
+bootstrap: ${allsrc} | ${Revision}
$(MAKE) allx
touch bootstrap
@@ -516,6 +517,10 @@ ${Cequates}: mkheader.so ${macroobj} nanopass.so base-lang.ss expand-lang.ss pri
then mv -f ${Cequates}.bak ${Cequates};\
else rm -f ${Cequates}.bak; fi)
+.PHONY: ${Revision}
+${Revision}: update-revision
+ @./update-revision > ${Revision}
+
examples:
( cd ../examples && ${MAKE} all Scheme="${Scheme} ../s/${patchfile}" )
diff --git a/s/update-revision b/s/update-revision
new file mode 100755
index 0000000000..0b6e3f6ed0
--- /dev/null
+++ b/s/update-revision
@@ -0,0 +1,22 @@
+#!/bin/bash
+if [ -d ../../.git ]; then
+ git describe --always --exclude='*' --abbrev=40 --dirty
+ echo 'git'
+elif [ -d ../../.hg ]; then
+ DIRTY="$(hg status -n --color never --pager never | head -1)"
+ hg log --limit 1 --template '{node}' --pager never
+ if [ -n "${DIRTY}" ]; then
+ echo '-dirty'
+ else
+ echo ''
+ fi
+ echo 'hg'
+elif [ -f ../../.hg_archival.txt ]; then
+ # hg archive and hgweb embed this file by default (see .hgrc archivemeta)
+ sed -n 's/^node: \(.*\)/\1/p' < ../../.hg_archival.txt
+ echo 'hg'
+else
+ # use export-subst git attribute to populate revision for git archive
+ echo '$Format:%H$'
+ echo 'git'
+fi
diff --git a/wininstall/a6nt.wxs b/wininstall/a6nt.wxs
index 6dd2e69396..c1d6cc28eb 100644
--- a/wininstall/a6nt.wxs
+++ b/wininstall/a6nt.wxs
@@ -63,6 +63,9 @@
+
+
+
@@ -82,6 +85,7 @@
+
diff --git a/wininstall/i3nt.wxs b/wininstall/i3nt.wxs
index 945c5ef287..a530b092fe 100644
--- a/wininstall/i3nt.wxs
+++ b/wininstall/i3nt.wxs
@@ -63,6 +63,9 @@
+
+
+
@@ -82,6 +85,7 @@
+
diff --git a/wininstall/ta6nt.wxs b/wininstall/ta6nt.wxs
index 19c315cf56..f137baa657 100644
--- a/wininstall/ta6nt.wxs
+++ b/wininstall/ta6nt.wxs
@@ -63,6 +63,9 @@
+
+
+
@@ -82,6 +85,7 @@
+
diff --git a/wininstall/ti3nt.wxs b/wininstall/ti3nt.wxs
index 1773f066d5..3c65019ef5 100644
--- a/wininstall/ti3nt.wxs
+++ b/wininstall/ti3nt.wxs
@@ -63,6 +63,9 @@
+
+
+
@@ -84,6 +87,7 @@
+