autogen.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #! /usr/bin/env bash
  2. set -e
  3. if [ ! -e grub-core/lib/gnulib/stdlib.in.h ]; then
  4. echo "Gnulib not yet bootstrapped; run ./bootstrap instead." >&2
  5. exit 1
  6. fi
  7. # Detect python
  8. if [ -z "$PYTHON" ]; then
  9. for i in python3 python3.10 python; do
  10. if command -v "$i" > /dev/null 2>&1; then
  11. PYTHON="$i"
  12. echo "Using $PYTHON..."
  13. break
  14. fi
  15. done
  16. if [ -z "$PYTHON" ]; then
  17. echo "python not found." >&2
  18. exit 1
  19. fi
  20. fi
  21. export LC_COLLATE=C
  22. unset LC_ALL
  23. 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
  24. find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
  25. echo "Importing unicode..."
  26. ${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
  27. echo "Importing libgcrypt..."
  28. ${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
  29. sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
  30. if [ -f include/grub/gcrypt/g10lib.h ]; then
  31. rm include/grub/gcrypt/g10lib.h
  32. fi
  33. if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then
  34. rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
  35. fi
  36. cp grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
  37. cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic
  38. 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
  39. if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ] || [ -f grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then
  40. rm grub-core/lib/libgcrypt-grub/mpi/"$x"
  41. fi
  42. cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
  43. done
  44. echo "Generating Automake input..."
  45. # Automake doesn't like including files from a path outside the project.
  46. rm -f contrib grub-core/contrib
  47. if [ "x${GRUB_CONTRIB}" != x ]; then
  48. [ "${GRUB_CONTRIB}" = contrib ] || ln -s "${GRUB_CONTRIB}" contrib
  49. [ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
  50. fi
  51. UTIL_DEFS='Makefile.util.def Makefile.utilgcry.def'
  52. CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
  53. for extra in contrib/*/Makefile.util.def; do
  54. if test -e "$extra"; then
  55. UTIL_DEFS="$UTIL_DEFS $extra"
  56. fi
  57. done
  58. for extra in contrib/*/Makefile.core.def; do
  59. if test -e "$extra"; then
  60. CORE_DEFS="$CORE_DEFS $extra"
  61. fi
  62. done
  63. ${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
  64. ${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
  65. for extra in contrib/*/Makefile.common; do
  66. if test -e "$extra"; then
  67. echo "include $extra" >> Makefile.util.am
  68. echo "include $extra" >> grub-core/Makefile.core.am
  69. fi
  70. done
  71. for extra in contrib/*/Makefile.util.common; do
  72. if test -e "$extra"; then
  73. echo "include $extra" >> Makefile.util.am
  74. fi
  75. done
  76. for extra in contrib/*/Makefile.core.common; do
  77. if test -e "$extra"; then
  78. echo "include $extra" >> grub-core/Makefile.core.am
  79. fi
  80. done
  81. echo "Saving timestamps..."
  82. echo timestamp > stamp-h.in
  83. if [ -z "$FROM_BOOTSTRAP" ]; then
  84. # Unaided autoreconf is likely to install older versions of many files
  85. # than the ones provided by Gnulib, but in most cases this won't matter
  86. # very much. This mode is provided so that you can run ./autogen.sh to
  87. # regenerate the GRUB build system in an unpacked release tarball (perhaps
  88. # after patching it), even on systems that don't have access to
  89. # gnulib.git.
  90. echo "Running autoreconf..."
  91. cp -a INSTALL INSTALL.grub
  92. autoreconf -vif
  93. mv INSTALL.grub INSTALL
  94. fi
  95. exit 0