autogen.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 "Importing libtasn1..."
  45. if [ -d grub-core/lib/libtasn1-grub ]; then
  46. rm -rf grub-core/lib/libtasn1-grub
  47. fi
  48. mkdir -p grub-core/lib/libtasn1-grub/lib
  49. cp grub-core/lib/libtasn1/lib/*.[ch] grub-core/lib/libtasn1-grub/lib
  50. cp grub-core/lib/libtasn1/libtasn1.h grub-core/lib/libtasn1-grub/
  51. if [ -d grub-core/tests/asn1/tests ]; then
  52. rm -rf grub-core/tests/asn1/tests
  53. fi
  54. mkdir grub-core/tests/asn1/tests
  55. cp grub-core/lib/libtasn1/tests/*.[ch] grub-core/tests/asn1/tests
  56. for patch in \
  57. 0001-libtasn1-disable-code-not-needed-in-grub.patch \
  58. 0002-libtasn1-replace-strcat-with-strcpy-in-_asn1_str_cat.patch \
  59. 0003-libtasn1-replace-strcat-with-_asn1_str_cat.patch \
  60. 0004-libtasn1-adjust-the-header-paths-in-libtasn1.h.patch \
  61. 0005-libtasn1-Use-grub_divmod64-for-division.patch \
  62. 0006-libtasn1-fix-the-potential-buffer-overrun.patch \
  63. 0007-asn1_test-include-asn1_test.h-only.patch \
  64. 0008-asn1_test-rename-the-main-functions-to-the-test-name.patch \
  65. 0009-asn1_test-return-either-0-or-1-to-reflect-the-result.patch \
  66. 0010-asn1_test-remove-verbose-and-the-unnecessary-printf.patch \
  67. 0011-asn1_test-print-the-error-messages-with-grub_printf.patch \
  68. 0012-asn1_test-use-the-grub-specific-functions-and-types.patch \
  69. 0013-asn1_test-enable-the-testcase-only-when-GRUB_LONG_MA.patch ; do
  70. patch -p1 -i grub-core/lib/libtasn1-patches/$patch
  71. done
  72. echo "Generating Automake input..."
  73. # Automake doesn't like including files from a path outside the project.
  74. rm -f contrib grub-core/contrib
  75. if [ "x${GRUB_CONTRIB}" != x ]; then
  76. [ "${GRUB_CONTRIB}" = contrib ] || ln -s "${GRUB_CONTRIB}" contrib
  77. [ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
  78. fi
  79. UTIL_DEFS='Makefile.util.def Makefile.utilgcry.def'
  80. CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
  81. for extra in contrib/*/Makefile.util.def; do
  82. if test -e "$extra"; then
  83. UTIL_DEFS="$UTIL_DEFS $extra"
  84. fi
  85. done
  86. for extra in contrib/*/Makefile.core.def; do
  87. if test -e "$extra"; then
  88. CORE_DEFS="$CORE_DEFS $extra"
  89. fi
  90. done
  91. ${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
  92. ${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
  93. for extra in contrib/*/Makefile.common; do
  94. if test -e "$extra"; then
  95. echo "include $extra" >> Makefile.util.am
  96. echo "include $extra" >> grub-core/Makefile.core.am
  97. fi
  98. done
  99. for extra in contrib/*/Makefile.util.common; do
  100. if test -e "$extra"; then
  101. echo "include $extra" >> Makefile.util.am
  102. fi
  103. done
  104. for extra in contrib/*/Makefile.core.common; do
  105. if test -e "$extra"; then
  106. echo "include $extra" >> grub-core/Makefile.core.am
  107. fi
  108. done
  109. echo "Saving timestamps..."
  110. echo timestamp > stamp-h.in
  111. if [ -z "$FROM_BOOTSTRAP" ]; then
  112. # Unaided autoreconf is likely to install older versions of many files
  113. # than the ones provided by Gnulib, but in most cases this won't matter
  114. # very much. This mode is provided so that you can run ./autogen.sh to
  115. # regenerate the GRUB build system in an unpacked release tarball (perhaps
  116. # after patching it), even on systems that don't have access to
  117. # gnulib.git.
  118. echo "Running autoreconf..."
  119. cp -a INSTALL INSTALL.grub
  120. autoreconf -vif
  121. mv INSTALL.grub INSTALL
  122. fi
  123. exit 0