ieee1275: split up grub_machine_get_bootlocation
[grub.git] / autogen.sh
index e41caa5..7537561 100755 (executable)
@@ -1,44 +1,86 @@
-#! /bin/sh
+#! /usr/bin/env bash
 
 set -e
 
-autogen --version >/dev/null || (echo autogen missing; exit 1)
-
-echo "Creating symlinks..."
-ln -svf ../NEWS grub-core/
-ln -svf ../TODO grub-core/
-ln -svf ../THANKS grub-core/
-ln -svf ../README grub-core/
-ln -svf ../INSTALL grub-core/
-ln -svf ../AUTHORS grub-core/
-ln -svf ../COPYING grub-core/
-ln -svf ../ABOUT-NLS grub-core/
-ln -svf ../ChangeLog grub-core/
-ln -svf ../aclocal.m4 grub-core/
-ln -svf ../acinclude.m4 grub-core/
-ln -svf ../config.rpath grub-core/
-ln -svf ../gentpl.py grub-core/
-ln -svf ../configure.common grub-core/
-
-echo "Creating Makefile.tpl..."
-python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
-echo "Running autogen..."
-autogen -T Makefile.tpl modules.def | sed -e '/^$/{N;/^\n$/D;}' > modules.am
-
-echo "Creating grub-core/Makefile.tpl..."
-(cd grub-core && python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl)
-echo "Running autogen..."
-(cd grub-core && autogen -T Makefile.tpl modules.def | sed -e '/^$/{N;/^\n$/D;}' > modules.am)
+# Set ${PYTHON} to plain 'python' if not set already
+: ${PYTHON:=python}
+
+export LC_COLLATE=C
+unset LC_ALL
+
+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' |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..."
-(cd grub-core && python import_gcry.py lib/libgcrypt/ .)
+${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
+fi
+if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then 
+    rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
+fi
+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
+    cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
+done
+
+echo "Generating Automake input..."
+
+# Automake doesn't like including files from a path outside the project.
+rm -f contrib grub-core/contrib
+if [ "x${GRUB_CONTRIB}" != x ]; then
+  [ "${GRUB_CONTRIB}" = contrib ] || ln -s "${GRUB_CONTRIB}" contrib
+  [ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
+fi
+
+UTIL_DEFS='Makefile.util.def Makefile.utilgcry.def'
+CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
+
+for extra in contrib/*/Makefile.util.def; do
+  if test -e "$extra"; then
+    UTIL_DEFS="$UTIL_DEFS $extra"
+  fi
+done
+
+for extra in contrib/*/Makefile.core.def; do
+  if test -e "$extra"; then
+    CORE_DEFS="$CORE_DEFS $extra"
+  fi
+done
+
+${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 "include $extra" >> Makefile.util.am
+    echo "include $extra" >> grub-core/Makefile.core.am
+  fi
+done
+
+for extra in contrib/*/Makefile.util.common; do
+  if test -e "$extra"; then
+    echo "include $extra" >> Makefile.util.am
+  fi
+done
+
+for extra in contrib/*/Makefile.core.common; do
+  if test -e "$extra"; then
+    echo "include $extra" >> grub-core/Makefile.core.am
+  fi
+done
 
 echo "Saving timestamps..."
 echo timestamp > stamp-h.in
-(cd grub-core && echo timestamp > stamp-h.in)
 
 echo "Running autoreconf..."
 autoreconf -vi