set -e
-export LC_CTYPE=C
+if [ ! -e grub-core/lib/gnulib/stdlib.in.h ]; then
+ echo "Gnulib not yet bootstrapped; run ./bootstrap instead." >&2
+ exit 1
+fi
+
+# Set ${PYTHON} to plain 'python' if not set already
+: ${PYTHON:=python}
+
export LC_COLLATE=C
unset LC_ALL
-find . -iname '*.[ch]' -not -ipath './grub-core/lib/libgcrypt-grub/*' -not -ipath './build-aux/*' -not -ipath './grub-core/lib/libgcrypt/src/misc.c' -not -ipath './grub-core/lib/libgcrypt/src/global.c' -not -ipath './grub-core/lib/libgcrypt/src/secmem.c' |sort > po/POTFILES.in
-find util -iname '*.in' -not -name Makefile.in |sort > po/POTFILES-shell.in
-
-autogen --version >/dev/null || exit 1
+find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -ipath './grub-core/lib/gnulib/*' |sort > po/POTFILES.in
+find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
echo "Importing unicode..."
-python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
+${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
echo "Importing libgcrypt..."
-python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
+${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
if [ -f include/grub/gcrypt/g10lib.h ]; then
rm include/grub/gcrypt/g10lib.h
if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then
rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
fi
-ln -s ../../../grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
+cp grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic
for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul3.c mpih-lshift.c mpih-rshift.c; do
if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ] || [ -f grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then
rm grub-core/lib/libgcrypt-grub/mpi/"$x"
fi
- ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
+ cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
done
-echo "Creating Makefile.tpl..."
-python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
-
-echo "Running autogen..."
+echo "Generating Automake input..."
# Automake doesn't like including files from a path outside the project.
rm -f contrib grub-core/contrib
fi
done
-cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
-cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
+${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
+${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
for extra in contrib/*/Makefile.common; do
if test -e "$extra"; then
echo "Saving timestamps..."
echo timestamp > stamp-h.in
-echo "Running autoreconf..."
-autoreconf -vi
+if [ -z "$FROM_BOOTSTRAP" ]; then
+ # Unaided autoreconf is likely to install older versions of many files
+ # than the ones provided by Gnulib, but in most cases this won't matter
+ # very much. This mode is provided so that you can run ./autogen.sh to
+ # regenerate the GRUB build system in an unpacked release tarball (perhaps
+ # after patching it), even on systems that don't have access to
+ # gnulib.git.
+ echo "Running autoreconf..."
+ cp -a INSTALL INSTALL.grub
+ autoreconf -vif
+ mv INSTALL.grub INSTALL
+fi
+
exit 0