]> git.ipfire.org Git - thirdparty/grub.git/blob - autogen.sh
build: Allow explicit module dependencies
[thirdparty/grub.git] / autogen.sh
1 #! /usr/bin/env bash
2
3 set -e
4
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
9
10 # Detect python
11 if [ -z "$PYTHON" ]; then
12 for i in python3 python; do
13 if command -v "$i" > /dev/null 2>&1; then
14 PYTHON="$i"
15 echo "Using $PYTHON..."
16 break
17 fi
18 done
19
20 if [ -z "$PYTHON" ]; then
21 echo "python not found." >&2
22 exit 1
23 fi
24 fi
25
26 export LC_COLLATE=C
27 unset LC_ALL
28
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
31
32 echo "Importing unicode..."
33 ${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
34
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
40 fi
41 if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then
42 rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
43 fi
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
46
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"
50 fi
51 cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
52 done
53
54 echo "Generating Automake input..."
55
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
61 fi
62
63 UTIL_DEFS='Makefile.util.def Makefile.utilgcry.def'
64 CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
65
66 for extra in contrib/*/Makefile.util.def; do
67 if test -e "$extra"; then
68 UTIL_DEFS="$UTIL_DEFS $extra"
69 fi
70 done
71
72 for extra in contrib/*/Makefile.core.def; do
73 if test -e "$extra"; then
74 CORE_DEFS="$CORE_DEFS $extra"
75 fi
76 done
77
78 ${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
79 ${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
80
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
85 fi
86 done
87
88 for extra in contrib/*/Makefile.util.common; do
89 if test -e "$extra"; then
90 echo "include $extra" >> Makefile.util.am
91 fi
92 done
93
94 for extra in contrib/*/Makefile.core.common; do
95 if test -e "$extra"; then
96 echo "include $extra" >> grub-core/Makefile.core.am
97 fi
98 done
99
100 echo "Saving timestamps..."
101 echo timestamp > stamp-h.in
102
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
114 fi
115
116 exit 0