diff --git a/Makefile.in b/Makefile.in
index 3d208e7..6b56c83 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -419,6 +419,16 @@ gensymlist.sh: gensymlist.sh.in config.status
genkernsyms.sh: genkernsyms.sh.in config.status
$(SHELL) ./config.status
+genversionstr.sh: genversionstr.sh.in config.status
+ $(SHELL) ./config.status
+
+# Build version string
+grub_version.h: genversionstr.sh ChangeLog
+ $(SHELL) ./genversionstr.sh > $@ || (rm -f $@ ; exit 1)
+
+normal_mod-normal_main.o: grub_version.h
+
+
.PHONY: all install install-strip uninstall clean mostlyclean distclean
.PHONY: maintainer-clean info dvi dist check
diff --git a/configure.ac b/configure.ac
index 8b12c58..890cf3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -529,6 +529,6 @@ else
rm -rf include/grub/machine
cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
fi
-AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
+AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh genversionstr.sh])
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
AC_OUTPUT
diff --git a/genversionstr.sh.in b/genversionstr.sh.in
new file mode 100644
index 0000000..6e58fb3
--- /dev/null
+++ b/genversionstr.sh.in
@@ -0,0 +1,77 @@
+#! /bin/sh
+#
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# This genversionstr.sh.in is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+### The configure script will replace these variables.
+
+srcdir=@srcdir@
+
+
+cat <.
+ */
+
+EOF
+
+
+if sed -n '2,/^20/p' $srcdir/ChangeLog \
+ | grep 'configure.ac (AC_INIT): Bumped' >/dev/null 2>/dev/null
+then
+ # Last entry documents new PACKAGE_VERSION, assume official release
+
+ cat < /dev/null \
+ | sed -n 's,^Revision: *\(.*\)$,-r\1,p'
+ `
+ fi
+
+ cat <
#include
+#include "grub_version.h"
+
#define GRUB_DEFAULT_HISTORY_SIZE 50
/* Read a line from the file FILE. */
@@ -375,7 +377,7 @@ grub_normal_init_page (void)
{
grub_uint8_t width, margin;
-#define TITLE ("GNU GRUB version " PACKAGE_VERSION)
+#define TITLE ("GNU GRUB version " GRUB_VERSION)
width = grub_getwh () >> 8;
margin = (width - (sizeof(TITLE) + 7)) / 2;