merge mainline into arm
[grub.git] / autogen.sh
1 #! /usr/bin/env bash
2
3 set -e
4
5 export LC_CTYPE=C
6 export LC_COLLATE=C
7 unset LC_ALL
8
9 find . -iname '*.[ch]' -not -ipath './grub-core/lib/libgcrypt-grub/*' -not -ipath './build-aux/*' -not -ipath './grub-core/lib/libgcrypt/src/misc.c' -not -ipath './grub-core/lib/libgcrypt/src/global.c' -not -ipath './grub-core/lib/libgcrypt/src/secmem.c' |sort > po/POTFILES.in
10 find util -iname '*.in' -not -name Makefile.in  |sort > po/POTFILES-shell.in
11
12 autogen --version >/dev/null || exit 1
13
14 echo "Importing unicode..."
15 python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
16
17 echo "Importing libgcrypt..."
18 python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
19 sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
20 if [ -f include/grub/gcrypt/g10lib.h ]; then
21     rm include/grub/gcrypt/g10lib.h
22 fi
23 if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then 
24     rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
25 fi
26 ln -s ../../../grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
27 cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic
28
29 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
30     if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ] || [ -f grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then
31         rm grub-core/lib/libgcrypt-grub/mpi/"$x"
32     fi
33     ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
34 done
35
36 echo "Importing libfdt..."
37 python util/import_libfdt.py grub-core/lib/dtc/ grub-core
38
39 echo "Creating Makefile.tpl..."
40 python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
41
42 echo "Running autogen..."
43
44 # Automake doesn't like including files from a path outside the project.
45 rm -f contrib grub-core/contrib
46 if [ "x${GRUB_CONTRIB}" != x ]; then
47   [ "${GRUB_CONTRIB}" = contrib ] || ln -s "${GRUB_CONTRIB}" contrib
48   [ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
49 fi
50
51 UTIL_DEFS='Makefile.util.def Makefile.utilgcry.def'
52 CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def grub-core/Makefile.libfdt.def'
53
54 for extra in contrib/*/Makefile.util.def; do
55   if test -e "$extra"; then
56     UTIL_DEFS="$UTIL_DEFS $extra"
57   fi
58 done
59
60 for extra in contrib/*/Makefile.core.def; do
61   if test -e "$extra"; then
62     CORE_DEFS="$CORE_DEFS $extra"
63   fi
64 done
65
66 cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
67 cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
68
69 for extra in contrib/*/Makefile.common; do
70   if test -e "$extra"; then
71     echo "include $extra" >> Makefile.util.am
72     echo "include $extra" >> grub-core/Makefile.core.am
73   fi
74 done
75
76 for extra in contrib/*/Makefile.util.common; do
77   if test -e "$extra"; then
78     echo "include $extra" >> Makefile.util.am
79   fi
80 done
81
82 for extra in contrib/*/Makefile.core.common; do
83   if test -e "$extra"; then
84     echo "include $extra" >> grub-core/Makefile.core.am
85   fi
86 done
87
88 echo "Saving timestamps..."
89 echo timestamp > stamp-h.in
90
91 echo "Running autoreconf..."
92 autoreconf -vi
93 exit 0