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