* autogen.sh: Use "-h", not "-f", to test for existence of symbolic
[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 autogen --version >/dev/null || exit 1
10
11 echo "Importing unicode..."
12 python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
13
14 echo "Importing libgcrypt..."
15 python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
16 sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
17 if [ -f include/grub/gcrypt/g10lib.h ]; then
18     rm include/grub/gcrypt/g10lib.h
19 fi
20 if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then 
21     rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
22 fi
23 ln -s ../../../grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
24 cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic
25
26 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
27     if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then
28         rm grub-core/lib/libgcrypt-grub/mpi/"$x"
29     fi
30     ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
31 done
32
33 echo "Creating Makefile.tpl..."
34 python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
35
36 echo "Running autogen..."
37
38 # Automake doesn't like including files from a path outside the project.
39 rm -f contrib grub-core/contrib
40 if [ "x${GRUB_CONTRIB}" != x ]; then
41   [ "${GRUB_CONTRIB}" = contrib ] || ln -s "${GRUB_CONTRIB}" contrib
42   [ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
43 fi
44
45 UTIL_DEFS='Makefile.util.def Makefile.utilgcry.def'
46 CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
47
48 for extra in contrib/*/Makefile.util.def; do
49   if test -e "$extra"; then
50     UTIL_DEFS="$UTIL_DEFS $extra"
51   fi
52 done
53
54 for extra in contrib/*/Makefile.core.def; do
55   if test -e "$extra"; then
56     CORE_DEFS="$CORE_DEFS $extra"
57   fi
58 done
59
60 cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
61 cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
62
63 for extra in contrib/*/Makefile.common; do
64   if test -e "$extra"; then
65     echo "include $extra" >> Makefile.util.am
66     echo "include $extra" >> grub-core/Makefile.core.am
67   fi
68 done
69
70 for extra in contrib/*/Makefile.util.common; do
71   if test -e "$extra"; then
72     echo "include $extra" >> Makefile.util.am
73   fi
74 done
75
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
82 echo "Saving timestamps..."
83 echo timestamp > stamp-h.in
84
85 echo "Running autoreconf..."
86 autoreconf -vi
87 exit 0