Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 1522)
+++ /trunk/Config.kmk	(revision 1523)
@@ -40,4 +40,54 @@
 	KBUILD_VERSION_MINOR=$(KBUILD_VERSION_MINOR) \
 	KBUILD_VERSION_PATCH=$(KBUILD_VERSION_PATCH)
+
+#
+# Get the svn version.
+# This is shipped with the tarballs in a SvnInfo.kmk in the root.
+#
+ifneq ($(wildcard $(PATH_ROOT)/SvnInfo.kmk),)
+# Shipped
+KBUILD_SVN_INFO_KMK := $(PATH_ROOT)/SvnInfo.kmk
+KBUILD_SVN_INFO_DEP := $(KBUILD_SVN_INFO_KMK)
+
+else ifneq ($(wildcard $(PATH_ROOT)/.svn/entries),)
+# Generate from svn info
+KBUILD_SVN_INFO_KMK := $(PATH_OBJ)/SvnInfo.kmk
+KBUILD_SVN_INFO_DEP := $(KBUILD_SVN_INFO_KMK)
+
+$(PATH_OBJ)/SvnInfo.ts +| $(KBUILD_SVN_INFO_KMK): $(PATH_ROOT)/.svn/entries $(PATH_ROOT)/.svn/all-wcprops $(PATH_ROOT)/.svn/format
+	$(call MSG_GENERATE,,$(KBUILD_SVN_INFO_KMK))
+	@$(RM) -f $@ $@.tmp
+	@$(MKDIR) -p $(@D)
+	@$(REDIRECT) -o $@.tmp -- svn info $(DEPTH)
+	@$(SED) \
+		-e 's/URL: */KBUILD_SVN_URL := /' \
+		-e 's/Revision: */KBUILD_SVN_REV := /' \
+		-e '/KBUILD_SVN_/!d' \
+		--append $@ \
+		$@.tmp
+	@$(RM) -f $@.tmp
+	@$(CP) --changed -fv $@ $(KBUILD_SVN_INFO_KMK)
+
+ ifeq ($(DEPTH),.)
+OTHER_CLEAN += $(KBUILD_SVN_INFO_KMK) $(PATH_OBJ)/SvnInfo.ts
+ endif
+
+else
+# Some incomplete source export...
+KBUILD_SVN_INFO_KMK := $(PATH_OBJ)/SvnInfo.kmk
+KBUILD_SVN_INFO_DEP := $(KBUILD_SVN_INFO_KMK)
+$(warning Neither SvnInfo nor .svn/* was found in the root. Will have to cook up something too keep the build happy.)
+$(KBUILD_SVN_INFO_KMK): $(PATH_ROOT)/.svn/entries $(PATH_ROOT)/.svn/all-wcprops $(PATH_ROOT)/.svn/format
+	$(RM) -f $@
+	$(APPEND) $@ 'KBUILD_SVN_REV := 0'
+	$(APPEND) $@ 'KBUILD_SVN_URL := /dev/null'
+
+ ifeq ($(DEPTH),.)
+OTHER_CLEAN += $(KBUILD_SVN_INFO_KMK)
+ endif
+
+endif
+include $(KBUILD_SVN_INFO_KMK)
+
 
 #
@@ -195,2 +245,3 @@
 LIB_KUTIL = $(PATH_OBJ)/src/lib/kUtil/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kUtil$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
 
+
Index: /trunk/MakefileMaint.kmk
===================================================================
--- /trunk/MakefileMaint.kmk	(revision 1522)
+++ /trunk/MakefileMaint.kmk	(revision 1523)
@@ -28,48 +28,41 @@
 include $(PATH_KBUILD)/header.kmk
 
-#
-# Get svn info and parse it bit by bit (cygwin sucks).
-#
-$(PATH_TARGET)/svn-info.kmk + $(PATH_TARGET)/svn-info.tmp: .svn/entries .svn/all-wcprops .svn/format
-	$(MKDIR) -p $(@D)
-	$(RM) -f $@
-	$(REDIRECT) -o $(PATH_TARGET)/svn-info.tmp -- svn info .
-	$(SED) -e '/^URL:/!d' -e 's/URL: */KBUILD_SVN_URL :=/' --append $@ $(PATH_TARGET)/svn-info.tmp
-	$(SED) -e '/^Revision:/!d' -e 's/Revision: */KBUILD_SVN_REV :=/' --append $@ $(PATH_TARGET)/svn-info.tmp
-
-include $(PATH_TARGET)/svn-info.kmk
-
-CLEANS += \
-	$(PATH_TARGET)/svn-info.tmp \
-	$(PATH_TARGET)/svn-info.kmk 
-
 RMTREE = $(ECHO) todo: $(RM) -Rf
 RMTREE = rm -Rf
+SVN = svn
+TAR = tar
+GZIP = gzip
+
+ifeq ($(strip $(KBUILD_SVN_INFO_KMK)),)
+$(error wtf? KBUILD_SVN_INFO_KMK is empty!)
+endif
 
 #
 # Creates the source tarballs.
 #
-$(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar.gz: | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar.gz: | $(call DIRDEP,$(PATH_TARGET)) $(KBUILD_SVN_INFO_DEP)
 	$(RM) -f $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar.gz
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/
-	svn export . $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/
-	tar cvf $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar -C $(PATH_TARGET) kBuild-$(KBUILD_VERSION)/
-	gzip -9 $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar
+	$(SVN) export . $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/
+	$(INSTALL) $(KBUILD_SVN_INFO_KMK) $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/SvnInfo.kmk
+	$(TAR) cvf $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar -C $(PATH_TARGET) kBuild-$(KBUILD_VERSION)/
+	$(GZIP) -9 $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/
 
-CLEANS += \
+OTHER_CLEAN += \
 	$(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar \
 	$(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar.gz
 
 
-$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar.gz: | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar.gz: | $(call DIRDEP,$(PATH_TARGET)) $(KBUILD_SVN_INFO_DEP)
 	$(RM) -f $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar.gz
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/
-	svn export . $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/
-	tar cvf $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar -C $(PATH_TARGET) kBuild-$(KBUILD_SVN_REV)/
-	gzip -9 $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar
+	$(SVN) export . $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/
+	$(INSTALL) $(KBUILD_SVN_INFO_KMK) $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/SvnInfo.kmk
+	$(TAR) cvf $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar -C $(PATH_TARGET) kBuild-$(KBUILD_SVN_REV)/
+	$(GZIP) -9 $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/
 
-CLEANS += \
+OTHER_CLEAN += \
 	$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar \
 	$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar.gz
@@ -82,10 +75,10 @@
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/
 	$(MKDIR) -p $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)
-	svn export kBuild/ $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/kBuild/
-	tar cvf $(PATH_TARGET)/kBuild-$(KBUILD_VERSION).tar -C $(PATH_TARGET) kBuild-$(KBUILD_VERSION)/
-	gzip -9 $(PATH_TARGET)/kBuild-$(KBUILD_VERSION).tar
+	$(SVN) export kBuild/ $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/kBuild/
+	$(TAR) cvf $(PATH_TARGET)/kBuild-$(KBUILD_VERSION).tar -C $(PATH_TARGET) kBuild-$(KBUILD_VERSION)/
+	$(GZIP) -9 $(PATH_TARGET)/kBuild-$(KBUILD_VERSION).tar
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_VERSION)/
 
-CLEANS += \
+OTHER_CLEAN += \
 	$(PATH_TARGET)/kBuild-$(KBUILD_VERSION).tar \
 	$(PATH_TARGET)/kBuild-$(KBUILD_VERSION).tar.gz
@@ -96,10 +89,10 @@
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/
 	$(MKDIR) -p $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)
-	svn export kBuild/ $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/kBuild/
-	tar cvf $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV).tar -C $(PATH_TARGET) kBuild-$(KBUILD_SVN_REV)/
-	gzip -9 $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV).tar
+	$(SVN) export kBuild/ $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/kBuild/
+	$(TAR) cvf $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV).tar -C $(PATH_TARGET) kBuild-$(KBUILD_SVN_REV)/
+	$(GZIP) -9 $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV).tar
 	$(RMTREE) $(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)/
 
-CLEANS += \
+OTHER_CLEAN += \
 	$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV).tar \
 	$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV).tar.gz
@@ -110,6 +103,6 @@
 #
 tarballs: \
+	$(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar.gz \
 	$(PATH_TARGET)/kBuild-$(KBUILD_VERSION).tar.gz \
-	$(PATH_TARGET)/kBuild-$(KBUILD_VERSION)-src.tar.gz \
 	$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV).tar.gz \
 	$(PATH_TARGET)/kBuild-$(KBUILD_SVN_REV)-src.tar.gz
